Skip to content

Instantly share code, notes, and snippets.

View zsytssk's full-sized avatar
🐶
nothing important

张世阳 zsytssk

🐶
nothing important
View GitHub Profile

因为公司的项目接入了几个钱包项目,现在来总结下; 接入的钱包有:MetaMask,Binance, WalletConnect; 钱包的基本功能有登录、获取余额、转账,为此我写了一个钱包类型实现这些功能,当时是想如果后面有新的钱包接入只要实现这些接口就可以了,后面接入新的钱包真的是很方便,只需实现这些接口,基本不用改动页面的其他地方。以下是钱包的接口:

/** 智能合约钱包账户信息 */
type WalletAccountInfo = {
  name: string;
  address: string;
 balance: number;
0x88151AD86A66CA32F2CC7E3E7f807f522603CACA
@zsytssk
zsytssk / stateManager.ts
Created April 30, 2020 10:35
react hook
import { EventCom } from '../eventCom';
import { useState, useEffect } from 'react';
const StateEvent = {
ChangeCount: 'change_count',
ChangeTest: 'change_test',
};
class StateModel extends EventCom {
public count = 0;
public test = { x: 1 };
[{x: 1, y: 2}].map((item) => {return {x: item.x}})
use std::sync::{Arc, Mutex};
use std::thread;
#[derive(Debug)]
struct Test<T> {
arr: Vec<T>,
len: u8,
}
impl<T> Test<T> {
/** set object properties */
export function setProps<T>(data: T, props: Partial<T>) {
for (let key in props) {
if (!props.hasOwnProperty(key)) {
continue;
}
data[key] = props[key];
}
}
@zsytssk
zsytssk / randomItem.js
Created October 7, 2018 01:11
array random item
Math.floor(Math.random() * Math.floor(max));
@zsytssk
zsytssk / thenable.ts
Created August 18, 2018 03:38
Thenable Promise.resolve
function getDocumentSettings(resource: string): Thenable<ExampleSettings> {
if (!hasConfigurationCapability) {
return Promise.resolve(globalSettings);
}
let result = documentSettings.get(resource);
if (!result) {
result = connection.workspace.getConfiguration({
scopeUri: resource,
section: 'languageServerExample'
});
@zsytssk
zsytssk / regexAll.js
Last active August 18, 2018 03:15
regex match all
const text = `TypeScript lets you write JavaScript the way you really want to.
TypeScript is a typed superset of JavaScript that compiles to plain JavaScript.
ANY browser. ANY host. ANY OS. Open Source.
`;
const pattern = /\b[A-Z]{2,}\b/g;
let m;
while (m = pattern.exec(text)) {
console.log(m)
}
# user
# 复制文件名
user = require './inits/zsy'
# user = require './inits/atom-evernote/main'
# user = require './inits/expandselect'
atom.commands.add 'atom-workspace',
'user:test': (event) -> test(event)
test=(event) ->