1 changed files with 86 additions and 84 deletions
@ -1,92 +1,94 @@ |
|||||
impor TokenUtil from './TokenUtil.js' |
impor TokenUtil from './TokenUtil.js' |
||||
let fullWallet = { |
let fullWallet = { |
||||
"BTC": [{ |
"BTC": [{ |
||||
balance: 0, |
balance: 0, |
||||
|
name: "BTC", |
||||
|
coinList: [{ |
||||
name: "BTC", |
name: "BTC", |
||||
coinList: [{ |
xname: 'Bitcoin', |
||||
name: "BTC", |
|
||||
xname: 'Bitcoin', |
|
||||
balance: 0, |
|
||||
icon: require('@/static/tongyonh/bye.png') |
|
||||
}] |
|
||||
}], |
|
||||
"ETH": [ |
|
||||
balance: 0, |
|
||||
name: "ETH", |
|
||||
coinList: [{ |
|
||||
name: "ETH", |
|
||||
xname: 'Ethereum', |
|
||||
balance: 0, |
|
||||
icon: require('@/static/tongyonh/Frame3299.png') |
|
||||
}, |
|
||||
{ |
|
||||
name: "USDT", |
|
||||
xname: 'Tether USD', |
|
||||
balance: 0, |
|
||||
contractAddress: '0xdac17f958d2ee523a2206206994597c13d831ec7', |
|
||||
icon: require('@/static/tongyonh/img500.png') |
|
||||
} |
|
||||
] |
|
||||
], |
|
||||
"TRON": [ |
|
||||
balance: 0, |
balance: 0, |
||||
name: "TRON", |
icon: require('@/static/tongyonh/bye.png') |
||||
coinList: [{ |
}] |
||||
name: "TRX", |
}], |
||||
xname: 'TRON', |
"ETH": [ |
||||
balance: 0, |
balance: 0, |
||||
icon: require('@/static/tongyonh/tron1.png') |
name: "ETH", |
||||
}, |
coinList: [{ |
||||
{ |
name: "ETH", |
||||
name: "TRC20-USDT", |
xname: 'Ethereum', |
||||
xname: 'Tether USD', |
balance: 0, |
||||
balance: 0, |
icon: require('@/static/tongyonh/Frame3299.png') |
||||
contractAddress: 'TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t', |
|
||||
icon: require('@/static/tongyonh/tether_usd.png') |
|
||||
} |
|
||||
] |
|
||||
} |
|
||||
|
|
||||
let WalletUtil = { |
|
||||
//初次创建钱包
|
|
||||
initialWallet: function(mnemonic, password) { |
|
||||
let walletInfo = fullWallet; |
|
||||
let btc = TokenUtil.token.generateBtc(mnemonic); |
|
||||
walletInfo.BTC[0].password = password; |
|
||||
walletInfo.BTC[0].mnemonic = mnemonic; |
|
||||
walletInfo.BTC[0].privateKey = btc.privateKey; |
|
||||
walletInfo.BTC[0].address = btc.address; |
|
||||
let eth = TokenUtil.token.generateEth(mnemonic) |
|
||||
walletInfo.ETH[0].password = password; |
|
||||
walletInfo.ETH[0].mnemonic = mnemonic; |
|
||||
walletInfo.ETH[0].privateKey = eth.privateKey; |
|
||||
walletInfo.ETH[0].address = eth.mnemonic; |
|
||||
let tron = TokenUtil.token.generateTron(mnemonic); |
|
||||
walletInfo.TRON[0].mnemonic = mnemonic; |
|
||||
walletInfo.TRON[0].password = password; |
|
||||
walletInfo.TRON[0].privateKey = tron.privateKey; |
|
||||
walletInfo.TRON[0].address = tron.mnemonic; |
|
||||
uni.setStorageSync('walletInfo', walletInfo); |
|
||||
}, |
}, |
||||
//修改钱包名称
|
{ |
||||
updateWalletName: function(type, address, name) { |
name: "USDT", |
||||
let walletInfo = uni.getStorageSync('walletInfo'); |
xname: 'Tether USD', |
||||
for (var k = 0, length = walletInfo.length; k < length; k++) { |
balance: 0, |
||||
if (walletInfo[k].address === address) { |
contractAddress: '0xdac17f958d2ee523a2206206994597c13d831ec7', |
||||
walletInfo[k].name = name |
icon: require('@/static/tongyonh/img500.png') |
||||
break; |
} |
||||
} |
] |
||||
} |
], |
||||
uni.setStorageSync('walletInfo', walletInfo); |
"TRON": [ |
||||
|
balance: 0, |
||||
|
name: "TRON", |
||||
|
coinList: [{ |
||||
|
name: "TRX", |
||||
|
xname: 'TRON', |
||||
|
balance: 0, |
||||
|
icon: require('@/static/tongyonh/tron1.png') |
||||
}, |
}, |
||||
updateWalletName: function(type, address, name) { |
{ |
||||
let walletInfo = uni.getStorageSync('walletInfo'); |
name: "TRC20-USDT", |
||||
for (var k = 0, length = walletInfo.length; k < length; k++) { |
xname: 'Tether USD', |
||||
if (walletInfo[k].address === address) { |
balance: 0, |
||||
walletInfo[k].name = name |
contractAddress: 'TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t', |
||||
break; |
icon: require('@/static/tongyonh/tether_usd.png') |
||||
} |
} |
||||
} |
], |
||||
uni.setStorageSync('walletInfo', walletInfo); |
] |
||||
|
} |
||||
|
|
||||
|
let WalletUtil = { |
||||
|
//初次创建钱包
|
||||
|
initialWallet: function(mnemonic, password) { |
||||
|
let walletInfo = fullWallet; |
||||
|
let btc = TokenUtil.token.generateBtc(mnemonic); |
||||
|
walletInfo.BTC[0].password = password; |
||||
|
walletInfo.BTC[0].mnemonic = mnemonic; |
||||
|
walletInfo.BTC[0].privateKey = btc.privateKey; |
||||
|
walletInfo.BTC[0].address = btc.address; |
||||
|
let eth = TokenUtil.token.generateEth(mnemonic) |
||||
|
walletInfo.ETH[0].password = password; |
||||
|
walletInfo.ETH[0].mnemonic = mnemonic; |
||||
|
walletInfo.ETH[0].privateKey = eth.privateKey; |
||||
|
walletInfo.ETH[0].address = eth.mnemonic; |
||||
|
let tron = TokenUtil.token.generateTron(mnemonic); |
||||
|
walletInfo.TRON[0].mnemonic = mnemonic; |
||||
|
walletInfo.TRON[0].password = password; |
||||
|
walletInfo.TRON[0].privateKey = tron.privateKey; |
||||
|
walletInfo.TRON[0].address = tron.mnemonic; |
||||
|
uni.setStorageSync('walletInfo', walletInfo); |
||||
|
}, |
||||
|
//修改钱包名称
|
||||
|
updateWalletName: function(type, address, name) { |
||||
|
let walletInfo = uni.getStorageSync('walletInfo'); |
||||
|
for (var k = 0, length = walletInfo.length; k < length; k++) { |
||||
|
if (walletInfo[k].address === address) { |
||||
|
walletInfo[k].name = name |
||||
|
break; |
||||
|
} |
||||
|
} |
||||
|
uni.setStorageSync('walletInfo', walletInfo); |
||||
|
}, |
||||
|
updateWalletName: function(type, address, name) { |
||||
|
let walletInfo = uni.getStorageSync('walletInfo'); |
||||
|
for (var k = 0, length = walletInfo.length; k < length; k++) { |
||||
|
if (walletInfo[k].address === address) { |
||||
|
walletInfo[k].name = name |
||||
|
break; |
||||
} |
} |
||||
} |
} |
||||
|
uni.setStorageSync('walletInfo', walletInfo); |
||||
|
} |
||||
|
} |
||||
|
export default WalletUtil |
||||
|
Loading…
Reference in new issue