Compare commits
84 Commits
staking_tn
...
master
Author | SHA1 | Date |
---|---|---|
nico | 18da2be63d | 8 months ago |
Ganesha Upadhyaya | d580e4a659 | 2 years ago |
Ganesha Upadhyaya | 5eddd0feb2 | 2 years ago |
Artem | 71304c22ad | 2 years ago |
Ganesha Upadhyaya | 3c7061887f | 4 years ago |
Ganesha Upadhyaya | e3d04c6383 | 4 years ago |
Ganesha Upadhyaya | 0c7337918d | 4 years ago |
Ganesha Upadhyaya | e364c4ffea | 4 years ago |
Aaron Li | baaa09e41f | 4 years ago |
Aaron Li | f29f2586dd | 4 years ago |
Isaac Adams | 87d5f999ab | 4 years ago |
Isaac Adams | 42d6400ee1 | 4 years ago |
Isaac Adams | 75a7118e1b | 4 years ago |
vinyl704 | 9d13ab257c | 4 years ago |
dependabot[bot] | 21be4e3fe3 | 4 years ago |
Ganesha Upadhyaya | 99a827782f | 4 years ago |
Ganesha Upadhyaya | 2acbadf97a | 4 years ago |
Sebastian Johnsson | 99bd7ad3d5 | 4 years ago |
Ganesha Upadhyaya | a60117ceac | 4 years ago |
Ganesha Upadhyaya | 4099a321f3 | 4 years ago |
dependabot[bot] | 6ab7227ef3 | 4 years ago |
Ganesha Upadhyaya | 8f8e17fdae | 4 years ago |
Ganesha Upadhyaya | 2762c8edbf | 4 years ago |
Ganesha Upadhyaya | 2a3ad781b6 | 4 years ago |
Ganesha Upadhyaya | aea4ca0cc7 | 4 years ago |
Ganesha Upadhyaya | 13c0830916 | 4 years ago |
Ganesha Upadhyaya | a7979a569f | 4 years ago |
Ganesha Upadhyaya | 1b6e351aa8 | 4 years ago |
PeekPI | 6e2c1e7653 | 4 years ago |
peekpi | d5feeb8d78 | 4 years ago |
peekpi | 4261bc15bb | 4 years ago |
peekpi | 9aefc978f6 | 4 years ago |
peekpi | 95453ee2e7 | 4 years ago |
Ganesha Upadhyaya | caa57d360d | 4 years ago |
Ganesha Upadhyaya | bc2d3a6e8d | 4 years ago |
Ganesha Upadhyaya | 73b97c7d07 | 4 years ago |
Ganesha Upadhyaya | cc4872a9f9 | 4 years ago |
Ganesha Upadhyaya | c6fbf597a5 | 4 years ago |
Ganesha Upadhyaya | 995f6b8f40 | 4 years ago |
Ganesha Upadhyaya | 6bcac8640e | 4 years ago |
PeekPI | cdf471b830 | 4 years ago |
lixp | f0e8056f84 | 4 years ago |
lixp | 1b977860ad | 4 years ago |
PeekPI | 93393dc36c | 4 years ago |
Ganesha Upadhyaya | aaf148c1af | 4 years ago |
dependabot[bot] | f125047487 | 4 years ago |
dependabot[bot] | e4f72e293e | 4 years ago |
dependabot[bot] | 1c47f9c713 | 4 years ago |
Ganesha Upadhyaya | 85e0e76dc0 | 4 years ago |
Ganesha Upadhyaya | 7a8c0f9699 | 4 years ago |
Ganesha Upadhyaya | cda12363c9 | 4 years ago |
Ganesha Upadhyaya | fb2fe2925b | 4 years ago |
lixp | a7e248a433 | 4 years ago |
PeekPI | 08d8f5aaf4 | 4 years ago |
lixp | fd2481aa35 | 4 years ago |
lixp | cf6fd13b86 | 4 years ago |
PeekPI | 794a590238 | 4 years ago |
PeekPI | cc4df6b24e | 4 years ago |
dependabot[bot] | 43eb47107a | 4 years ago |
dependabot[bot] | 2a118ebb7f | 4 years ago |
dependabot[bot] | c8e1e7503c | 4 years ago |
dependabot[bot] | a81045946a | 4 years ago |
dependabot[bot] | 26e38e9e35 | 4 years ago |
Ganesha Upadhyaya | c49abc5691 | 4 years ago |
Ganesha Upadhyaya | ca83e5477c | 4 years ago |
Sebastian Johnsson | 14fb03f3f2 | 4 years ago |
lixp | 40e0db00c5 | 4 years ago |
lixp | 4e111973b9 | 4 years ago |
Dennis Won | 463cfdfb68 | 4 years ago |
Dennis Won | 4033b3f971 | 4 years ago |
Dennis Won | 018c2626fe | 4 years ago |
Dennis Won | b63aae6bfb | 4 years ago |
Ganesha Upadhyaya | aa1b811830 | 4 years ago |
Jong Hyuck Won | 2a1bcbbbbb | 4 years ago |
Dennis Won | e571c4bedc | 4 years ago |
Jong Hyuck Won | d34f347e9e | 4 years ago |
Dennis Won | b6a9e4cc85 | 4 years ago |
lixp | 6a0163eef4 | 4 years ago |
Ganesha Upadhyaya | 7dd958349b | 4 years ago |
lixp | 9aa0985993 | 4 years ago |
lixp | 7d5e968ce1 | 4 years ago |
Hiro | 084bcbb5db | 4 years ago |
Hirokryptor | 3bfe0deb4e | 4 years ago |
lixp | 0bf2f24333 | 4 years ago |
@ -1,5 +0,0 @@ |
||||
GENESIS_PRIV_KEY=45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e |
||||
HTTP_PROVIDER=http://localhost:9500 |
||||
CHAIN_TYPE=hmy |
||||
CHAIN_ID=2 |
||||
|
@ -1,5 +0,0 @@ |
||||
GENESIS_PRIV_KEY=45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e |
||||
HTTP_PROVIDER=http://localhost:9500 |
||||
CHAIN_TYPE=hmy |
||||
CHAIN_ID=2 |
||||
|
@ -1,88 +1,169 @@ |
||||
import {harmony} from './harmony'; |
||||
import fetch from 'jest-fetch-mock'; |
||||
import { woop, checkCalledMethod } from './woop'; |
||||
|
||||
import demoAccounts from '../fixtures/testAccount.json'; |
||||
import { RPCMethod } from '@woop-js/network'; |
||||
|
||||
const bc = harmony.blockchain; |
||||
const bc = woop.blockchain; |
||||
|
||||
const testAccount = demoAccounts.Accounts[1]; |
||||
|
||||
describe('e2e test blockchain', () => { |
||||
beforeEach(() => { |
||||
fetch.resetMocks(); |
||||
}); |
||||
// net_*
|
||||
it('should test net_peerCount', async () => { |
||||
fetch.mockResponseOnce( |
||||
JSON.stringify({"jsonrpc": "2.0", "id": 1, "result": "0x0"}), |
||||
); |
||||
const peerCount = await bc.net_peerCount(); |
||||
expect(harmony.utils.isHex(peerCount.result)).toEqual(true); |
||||
expect(checkCalledMethod(0, RPCMethod.PeerCount)).toEqual(true); |
||||
expect(woop.utils.isHex(peerCount.result)).toEqual(true); |
||||
}); |
||||
|
||||
it('should test net_version', async () => { |
||||
fetch.mockResponseOnce( |
||||
JSON.stringify({"jsonrpc": "2.0", "id": 1, "result": "5"}), |
||||
); |
||||
const netVersion = await bc.net_version(); |
||||
const versionNumber = parseInt(netVersion.result as string, 10); |
||||
expect(netVersion.result).toEqual(`${versionNumber}`); |
||||
expect(checkCalledMethod(0, RPCMethod.NetVersion)).toEqual(true); |
||||
}); |
||||
it('should test hmy_protocolVersion', async () => { |
||||
it('should test wiki_protocolVersion', async () => { |
||||
fetch.mockResponseOnce( |
||||
JSON.stringify({"jsonrpc": "2.0", "id": 1, "result": "0x10"}), |
||||
); |
||||
const protocolVersion = await bc.getProtocolVersion(); |
||||
expect(harmony.utils.isHex(protocolVersion.result)).toEqual(true); |
||||
expect(woop.utils.isHex(protocolVersion.result)).toEqual(true); |
||||
expect(checkCalledMethod(0, RPCMethod.ProtocolVersion)).toEqual(true); |
||||
}); |
||||
|
||||
// block chain info
|
||||
it('should test hmy_blockNumber', async () => { |
||||
it('should test wiki_blockNumber', async () => { |
||||
fetch.mockResponseOnce( |
||||
JSON.stringify({"jsonrpc": "2.0", "id": 1, "result": "0x10"}), |
||||
); |
||||
const res = await bc.getBlockNumber(); |
||||
expect(res.responseType).toEqual('raw'); |
||||
expect(harmony.utils.isHex(res.result)).toEqual(true); |
||||
expect(woop.utils.isHex(res.result)).toEqual(true); |
||||
expect(checkCalledMethod(0, RPCMethod.BlockNumber)).toEqual(true); |
||||
}); |
||||
it('should test hmy_getBlockByNumber', async () => { |
||||
const res = await bc.getBlockByNumber({blockNumber: 'latest'}); |
||||
|
||||
it('should test wiki_getBlockByNumber', async () => { |
||||
fetch.mockResponse( |
||||
JSON.stringify({ |
||||
"jsonrpc": "2.0", |
||||
"id": 1, |
||||
"result": { |
||||
"size": "0x1", |
||||
"difficulty": 5, |
||||
"extraData": "0x", |
||||
"gasLimit": "0x80", |
||||
"gasUsed": "0x40", |
||||
"hash": "0x8a3390ab500Fbca6514eB326d2fcD9B3BFCFbA7DA392593cB4885b8e3399a2D8", |
||||
"logsBloom": "0x0", |
||||
"miner": "one155jp2y76nazx8uw5sa94fr0m4s5aj8e5xm6fu3", |
||||
"mixHash": "0x3A7c1Ae14AfecFf55Da298F66b75F4FfB771c3EaBDeAa267FF33A77d4d0be220", |
||||
"nonce": 1, |
||||
"number": "0x1", |
||||
"parentHash": "0x7CebC07e456F0bCD09dbc9A6f271074d93E27B40A4C67Dcc402e6513e12B9aF9", |
||||
"receiptsRoot": "0x02B82e11eDC07775Dc6fCF706be2cdAF9165750Ea7bC1B3Eb48ea16Bb3072F4D", |
||||
"stateRoot": "0xAaDc89C8bA4e3fCfC140cFcc8D3efD3BE7a49ab31534A5a3F0E1DEA09aae0f4a", |
||||
"timestamp": "0x62c44c0a", |
||||
"transactionsRoot": "0xc4bfa888fDCC8ca70E2b0CcdCEcc2fF545acCC2D655Ba33DaF4aBc31cFDBd9Ac", |
||||
"uncles": [] |
||||
} |
||||
}), |
||||
); |
||||
const res = await bc.getBlockByNumber({ blockNumber: 'latest' }); |
||||
const size = res.result.size; |
||||
expect(res.responseType).toEqual('raw'); |
||||
expect(harmony.utils.isHex(size)).toEqual(true); |
||||
expect(woop.utils.isHex(size)).toEqual(true); |
||||
expect(checkBlockData(res.result)).toEqual(true); |
||||
const res2 = await bc.getBlockByNumber({blockNumber: res.result.number}); |
||||
const res2 = await bc.getBlockByNumber({ blockNumber: res.result.number }); |
||||
expect(res2.responseType).toEqual('raw'); |
||||
expect(harmony.utils.isHex(res2.result.size)).toEqual(true); |
||||
expect(woop.utils.isHex(res2.result.size)).toEqual(true); |
||||
expect(checkBlockData(res2.result)).toEqual(true); |
||||
const res3 = await bc.getBlockByNumber({returnObject: true}); |
||||
const res3 = await bc.getBlockByNumber({ returnObject: true }); |
||||
expect(res3.responseType).toEqual('raw'); |
||||
expect(checkBlockData(res3.result)).toEqual(true); |
||||
for(let i = 0; i < 3; i++) { |
||||
expect(checkCalledMethod(i, RPCMethod.GetBlockByNumber)).toEqual(true); |
||||
} |
||||
}); |
||||
|
||||
it('should test hmy_getBlockByHash', async () => { |
||||
const latestBlock = await bc.getBlockByNumber({blockNumber: 'latest'}); |
||||
const res = await bc.getBlockByHash({blockHash: latestBlock.result.hash}); |
||||
it('should test wiki_getBlockByHash', async () => { |
||||
fetch.mockResponse( |
||||
JSON.stringify({ |
||||
"jsonrpc": "2.0", |
||||
"id": 1, |
||||
"result": { |
||||
"size": "0x1", |
||||
"difficulty": 5, |
||||
"extraData": "0x", |
||||
"gasLimit": "0x80", |
||||
"gasUsed": "0x40", |
||||
"hash": "0x8a3390ab500Fbca6514eB326d2fcD9B3BFCFbA7DA392593cB4885b8e3399a2D8", |
||||
"logsBloom": "0x0", |
||||
"miner": "one155jp2y76nazx8uw5sa94fr0m4s5aj8e5xm6fu3", |
||||
"mixHash": "0x3A7c1Ae14AfecFf55Da298F66b75F4FfB771c3EaBDeAa267FF33A77d4d0be220", |
||||
"nonce": 1, |
||||
"number": "0x1", |
||||
"parentHash": "0x7CebC07e456F0bCD09dbc9A6f271074d93E27B40A4C67Dcc402e6513e12B9aF9", |
||||
"receiptsRoot": "0x02B82e11eDC07775Dc6fCF706be2cdAF9165750Ea7bC1B3Eb48ea16Bb3072F4D", |
||||
"stateRoot": "0xAaDc89C8bA4e3fCfC140cFcc8D3efD3BE7a49ab31534A5a3F0E1DEA09aae0f4a", |
||||
"timestamp": "0x62c44c0a", |
||||
"transactionsRoot": "0xc4bfa888fDCC8ca70E2b0CcdCEcc2fF545acCC2D655Ba33DaF4aBc31cFDBd9Ac", |
||||
"uncles": [] |
||||
} |
||||
}), |
||||
); |
||||
const latestBlock = await bc.getBlockByNumber({ blockNumber: 'latest' }); |
||||
const res = await bc.getBlockByHash({ blockHash: latestBlock.result.hash }); |
||||
expect(res.responseType).toEqual('raw'); |
||||
expect(latestBlock.result.hash).toEqual(res.result.hash); |
||||
expect(harmony.utils.isHex(res.result.size)).toEqual(true); |
||||
expect(woop.utils.isHex(res.result.size)).toEqual(true); |
||||
expect(checkBlockData(res.result)).toEqual(true); |
||||
expect(checkCalledMethod(0, RPCMethod.GetBlockByNumber)).toEqual(true); |
||||
expect(checkCalledMethod(1, RPCMethod.GetBlockByHash)).toEqual(true); |
||||
}); |
||||
|
||||
// account related
|
||||
it('should test hmy_getBalance', async () => { |
||||
const balance = await bc.getBalance({address: testAccount.Address}); |
||||
expect(harmony.utils.isHex(balance.result)).toEqual(true); |
||||
it('should test wiki_getBalance', async () => { |
||||
fetch.mockResponseOnce( |
||||
JSON.stringify({"jsonrpc": "2.0", "id": 1, "result": "0x10"}), |
||||
); |
||||
const balance = await bc.getBalance({ address: testAccount.Address }); |
||||
expect(woop.utils.isHex(balance.result)).toEqual(true); |
||||
expect(checkCalledMethod(0, RPCMethod.GetBalance)).toEqual(true); |
||||
}); |
||||
}); |
||||
|
||||
function checkBlockData(data: any) { |
||||
return harmony.utils.validateArgs( |
||||
return woop.utils.validateArgs( |
||||
data, |
||||
{ |
||||
difficulty: [harmony.utils.isNumber], |
||||
difficulty: [woop.utils.isNumber], |
||||
// tslint:disable-next-line: no-shadowed-variable
|
||||
extraData: [(data: any) => data === '0x' || harmony.utils.isHex(data)], |
||||
gasLimit: [harmony.utils.isHex], |
||||
gasUsed: [harmony.utils.isHex], |
||||
hash: [harmony.utils.isHash], |
||||
logsBloom: [harmony.utils.isHex], |
||||
miner: [harmony.utils.isAddress], |
||||
mixHash: [harmony.utils.isHash], |
||||
nonce: [harmony.utils.isNumber], |
||||
number: [harmony.utils.isHex], |
||||
parentHash: [harmony.utils.isHash], |
||||
receiptsRoot: [harmony.utils.isHash], |
||||
size: [harmony.utils.isHex], |
||||
stateRoot: [harmony.utils.isHash], |
||||
timestamp: [harmony.utils.isHex], |
||||
transactionsRoot: [harmony.utils.isHash], |
||||
uncles: [harmony.utils.isArray], |
||||
extraData: [(data: any) => data === '0x' || woop.utils.isHex(data)], |
||||
gasLimit: [woop.utils.isHex], |
||||
gasUsed: [woop.utils.isHex], |
||||
hash: [woop.utils.isHash], |
||||
logsBloom: [woop.utils.isHex], |
||||
miner: [woop.utils.isBech32Address], |
||||
mixHash: [woop.utils.isHash], |
||||
nonce: [woop.utils.isNumber], |
||||
number: [woop.utils.isHex], |
||||
parentHash: [woop.utils.isHash], |
||||
receiptsRoot: [woop.utils.isHash], |
||||
size: [woop.utils.isHex], |
||||
stateRoot: [woop.utils.isHash], |
||||
timestamp: [woop.utils.isHex], |
||||
transactionsRoot: [woop.utils.isHash], |
||||
uncles: [woop.utils.isArray], |
||||
}, |
||||
{transactions: [harmony.utils.isArray]}, |
||||
{ transactions: [woop.utils.isArray] }, |
||||
); |
||||
} |
||||
} |
@ -1,29 +0,0 @@ |
||||
// tslint:disable-next-line: no-implicit-dependencies
|
||||
import { Harmony } from '@harmony-js/core'; |
||||
// tslint:disable-next-line: no-implicit-dependencies
|
||||
import { ChainType } from '@harmony-js/utils'; |
||||
// tslint:disable-next-line: no-implicit-dependencies
|
||||
import { Account } from '@harmony-js/account'; |
||||
|
||||
const CHAIN_ID: number = parseInt(process.env.CHAIN_ID as string, 10); |
||||
const CHAIN_TYPE: string = process.env.CHAIN_TYPE as string; |
||||
const HTTP_PROVIDER: string = process.env.HTTP_PROVIDER as string; |
||||
const GENESIS_PRIV_KEY: string = process.env.GENESIS_PRIV_KEY as string; |
||||
|
||||
let chainType: ChainType = ChainType.Harmony; |
||||
|
||||
if (CHAIN_TYPE === 'hmy') { |
||||
chainType = ChainType.Harmony; |
||||
} else if (CHAIN_TYPE === 'eth') { |
||||
chainType = ChainType.Ethereum; |
||||
} |
||||
|
||||
export const harmony: Harmony = new Harmony(HTTP_PROVIDER, { |
||||
chainId: CHAIN_ID, |
||||
chainType, |
||||
chainUrl: HTTP_PROVIDER, |
||||
}); |
||||
|
||||
export const myAccount: Account = harmony.wallet.addByPrivateKey( |
||||
GENESIS_PRIV_KEY, |
||||
); |
@ -0,0 +1,39 @@ |
||||
import fetch from 'jest-fetch-mock'; |
||||
// tslint:disable-next-line: no-implicit-dependencies
|
||||
import { Woop } from '@woop-js/core'; |
||||
// tslint:disable-next-line: no-implicit-dependencies
|
||||
import { ChainType } from '@woop-js/utils'; |
||||
// tslint:disable-next-line: no-implicit-dependencies
|
||||
import { Account } from '@woop-js/account'; |
||||
|
||||
const CHAIN_ID: number = 2; |
||||
const CHAIN_TYPE: string = 'wiki'; |
||||
const HTTP_PROVIDER: string = 'http://localhost:9500'; |
||||
const GENESIS_PRIV_KEY: string = '45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e'; |
||||
|
||||
let chainType: ChainType = ChainType.Woop; |
||||
|
||||
if (CHAIN_TYPE === 'wiki') { |
||||
chainType = ChainType.Woop; |
||||
} else if (CHAIN_TYPE === 'eth') { |
||||
chainType = ChainType.Ethereum; |
||||
} |
||||
|
||||
export const woop: Woop = new Woop(HTTP_PROVIDER, { |
||||
chainId: CHAIN_ID, |
||||
chainType, |
||||
chainUrl: HTTP_PROVIDER, |
||||
}); |
||||
|
||||
export const myAccount: Account = woop.wallet.addByPrivateKey( |
||||
GENESIS_PRIV_KEY, |
||||
); |
||||
|
||||
export function checkCalledMethod(i: number, s: string) { |
||||
let params: (string | undefined) = fetch.mock.calls[i][1]?.body?.toString(); |
||||
if (params) { |
||||
let method: string = JSON.parse(params).method; |
||||
return method === s; |
||||
} |
||||
return false; |
||||
} |
@ -1,134 +0,0 @@ |
||||
# Quick start |
||||
|
||||
1. You need Harmony local testnet running. |
||||
instruction here:[harmony-one/harmony](https://github.com/harmony-one/harmony) |
||||
2. Run this example under nodejs enviorment. |
||||
|
||||
```javascript |
||||
// import or require Harmony class |
||||
const { Harmony } = require('@harmony-js/core'); |
||||
|
||||
// import or require settings |
||||
const { ChainID, ChainType } = require('@harmony-js/utils'); |
||||
|
||||
// 1. initialize the Harmony instance |
||||
|
||||
const harmony = new Harmony( |
||||
// rpc url |
||||
'http://localhost:9500', |
||||
{ |
||||
// chainType set to Harmony |
||||
chainType: ChainType.Harmony, |
||||
// chainType set to HmyLocal |
||||
chainId: ChainID.HmyLocal, |
||||
}, |
||||
); |
||||
|
||||
// 2. get wallet ready |
||||
// specify the privateKey |
||||
const privateKey = '45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e'; |
||||
// add privateKey to wallet |
||||
const sender = harmony.wallet.addByPrivateKey(privateKey); |
||||
|
||||
// 3. get sharding info |
||||
async function setSharding() { |
||||
// Harmony is a sharded blockchain, each endpoint have sharding structure, |
||||
// However sharding structure is different between mainnet, testnet and local testnet |
||||
// We need to get sharding info before doing cross-shard transaction |
||||
const res = await harmony.blockchain.getShardingStructure(); |
||||
harmony.shardingStructures(res.result); |
||||
} |
||||
|
||||
// 4. get transaction payload ready |
||||
|
||||
async function transfer() { |
||||
// run set sharding first, if you want to make a cross-shard transaction |
||||
await setSharding(); |
||||
|
||||
const txn = harmony.transactions.newTx({ |
||||
// token send to |
||||
to: 'one166axnkjmghkf3df7xfvd0hn4dft8kemrza4cd2', |
||||
// amount to send |
||||
value: '10000', |
||||
// gas limit, you can use string |
||||
gasLimit: '210000', |
||||
// send token from shardID |
||||
shardID: 0, |
||||
// send token to toShardID |
||||
toShardID: 0, |
||||
// gas Price, you can use Unit class, and use Gwei, then remember to use toWei(), which will be transformed to BN |
||||
gasPrice: new harmony.utils.Unit('100').asGwei().toWei(), |
||||
}); |
||||
|
||||
// sign the transaction use wallet; |
||||
|
||||
const signedTxn = await harmony.wallet.signTransaction(txn); |
||||
|
||||
// Now you can use `Transaction.observed()` to listen events |
||||
|
||||
signedTxn |
||||
.observed() |
||||
.on('transactionHash', (txnHash) => { |
||||
console.log(''); |
||||
console.log('--- hash ---'); |
||||
console.log(''); |
||||
console.log(txnHash); |
||||
console.log(''); |
||||
}) |
||||
.on('receipt', (receipt) => { |
||||
console.log(''); |
||||
console.log('--- receipt ---'); |
||||
console.log(''); |
||||
console.log(receipt); |
||||
console.log(''); |
||||
}) |
||||
.on('cxReceipt', (receipt) => { |
||||
console.log(''); |
||||
console.log('--- cxReceipt ---'); |
||||
console.log(''); |
||||
console.log(receipt); |
||||
console.log(''); |
||||
}) |
||||
.on('error', (error) => { |
||||
console.log(''); |
||||
console.log('--- error ---'); |
||||
console.log(''); |
||||
console.log(error); |
||||
console.log(''); |
||||
}); |
||||
|
||||
// send the txn, get [Transaction, transactionHash] as result |
||||
|
||||
const [sentTxn, txnHash] = await signedTxn.sendTransaction(); |
||||
|
||||
// to confirm the result if it is already there |
||||
|
||||
const confiremdTxn = await sentTxn.confirm(txnHash); |
||||
|
||||
// if the transactino is cross-shard transaction |
||||
if (!confiremdTxn.isCrossShard()) { |
||||
if (confiremdTxn.isConfirmed()) { |
||||
console.log('--- Result ---'); |
||||
console.log(''); |
||||
console.log('Normal transaction'); |
||||
console.log(`${txnHash} is confirmed`); |
||||
console.log(''); |
||||
process.exit(); |
||||
} |
||||
} |
||||
if (confiremdTxn.isConfirmed() && confiremdTxn.isCxConfirmed()) { |
||||
console.log('--- Result ---'); |
||||
console.log(''); |
||||
console.log('Cross-Shard transaction'); |
||||
console.log(`${txnHash} is confirmed`); |
||||
console.log(''); |
||||
process.exit(); |
||||
} |
||||
} |
||||
|
||||
transfer(); |
||||
``` |
||||
|
||||
# More examples |
||||
|
||||
* [dapp-examples](https://github.com/harmony-one/dapp-examples) |
@ -1,31 +0,0 @@ |
||||
const { Harmony } = require('@harmony-js/core'); |
||||
|
||||
// import or require settings
|
||||
const { ChainID, ChainType } = require('@harmony-js/utils'); |
||||
|
||||
const URL_TESTNET = `https://api.s0.b.hmny.io`; |
||||
const URL_MAINNET = `https://api.s0.t.hmny.io`; |
||||
|
||||
// 1. initialize the Harmony instance
|
||||
|
||||
const harmony = new Harmony( |
||||
// rpc url
|
||||
URL_TESTNET, |
||||
{ |
||||
// chainType set to Harmony
|
||||
chainType: ChainType.Harmony, |
||||
// chainType set to HmyLocal
|
||||
chainId: ChainID.HmyTestnet, |
||||
}, |
||||
); |
||||
|
||||
harmony.blockchain |
||||
.getBalance({ |
||||
address: `one1vjywuur8ckddmc4dsyx6qdgf590eu07ag9fg4a`, |
||||
}) |
||||
.then((res) => { |
||||
console.log(new harmony.utils.Unit(res.result).asWei().toEther()); |
||||
}) |
||||
.catch((err) => { |
||||
console.log(err); |
||||
}); |
@ -1,45 +0,0 @@ |
||||
// import the Account class
|
||||
const { Account } = require('@harmony-js/account'); |
||||
|
||||
// suppose we have an account
|
||||
const myPrivateKey = '0x831f0b3ff835d5ec4602878742fda25591b6d3bb2731366621ac83a05216bec8'; |
||||
const myAccountWithMyPrivateKey = new Account(myPrivateKey); |
||||
|
||||
// suppose we have a password, and we want to encrypt the account above
|
||||
const myStrongPassword = '123'; |
||||
|
||||
async function encryptAndDecrypt(password) { |
||||
// we get the privateKey before encrypted as comparison
|
||||
const unencryptedPrivateKey = myAccountWithMyPrivateKey.privateKey; |
||||
|
||||
// export the account to keyStore string, which will make the privateKey encrpyted
|
||||
const keyStoreFile = await myAccountWithMyPrivateKey.toFile(password); |
||||
// exported keyStoreFile
|
||||
console.log({ keyStoreFile }); |
||||
// see if the account is encrypted
|
||||
console.log(`Is this account encrypted? \n ${myAccountWithMyPrivateKey.encrypted}`); |
||||
// keystore file should be equal to encrypted privateKey
|
||||
console.log( |
||||
`Is privateKey equal to keyStore string? \n ${keyStoreFile === |
||||
myAccountWithMyPrivateKey.privateKey}`,
|
||||
); |
||||
} |
||||
|
||||
encryptAndDecrypt(myStrongPassword); |
||||
|
||||
// suppose we have keyStorefile, in this example, we just use same password and keystore string encrypted above
|
||||
const someKeyStoreFile = |
||||
'{"version":3,"id":"38326265-6165-4961-a338-353063643962","address":"1cc87010760602a576455d6d2f03a3bf92d2c2ca","crypto":{"ciphertext":"a4ee9120b27ba66fb9d3fabd6372fa3a11060cf439a6a1777ced1e6253de8c29","cipherparams":{"iv":"c18772a882ac461fffd1971e9ec57861"},"cipher":"aes-128-ctr","kdf":"scrypt","kdfparams":{"salt":"da4efedeca407279be65e02fc94b7c4b7c74c3396447c71e659c74a73a5d9131","n":8192,"r":8,"p":1,"dklen":32},"mac":"547ee6616dcdf424273c113ceb00728ccdda17ff6449f2cb84a1a8352c87b4e6"}}'; |
||||
|
||||
async function importKeyStoreFileAndDecrypt(keyStoreFile, password) { |
||||
// import keyStore string and provide the password, remember to make a new Account first
|
||||
const importedAccount = await Account.new().fromFile(keyStoreFile, password); |
||||
// the account should decypted which `Account.encrypted` is false
|
||||
console.log(`Is this account encrypted? \n ${importedAccount.encrypted}`); |
||||
// see if the privatekey is equal to unencrypted one?
|
||||
console.log( |
||||
`Is the account recovered from keystore? \n ${importedAccount.privateKey === myPrivateKey}`, |
||||
); |
||||
} |
||||
|
||||
importKeyStoreFileAndDecrypt(someKeyStoreFile, myStrongPassword); |
@ -1,14 +0,0 @@ |
||||
{ |
||||
"name": "example", |
||||
"version": "1.0.0", |
||||
"description": "", |
||||
"main": "test.js", |
||||
"scripts": { |
||||
"test": "echo \"Error: no test specified\" && exit 1" |
||||
}, |
||||
"author": "", |
||||
"license": "ISC", |
||||
"dependencies": { |
||||
"@harmony-js/core": "^0.1.41" |
||||
} |
||||
} |
@ -1,79 +0,0 @@ |
||||
const { Harmony } = require('@harmony-js/core'); |
||||
const { ChainID, ChainType } = require('@harmony-js/utils'); |
||||
const { |
||||
StakingTransaction, |
||||
CreateValidator, |
||||
Delegate, |
||||
Undelegate, |
||||
CollectRewards, |
||||
StakingFactory, |
||||
} = require('@harmony-js/staking'); |
||||
|
||||
const harmony = new Harmony('http://localhost:9500', { |
||||
chainId: ChainID.HmyLocal, |
||||
chainType: ChainType.Harmony, |
||||
}); |
||||
|
||||
const stakingTxn = harmony.stakings |
||||
.createValidator({ |
||||
validatorAddress: 'one1a0x3d6xpmr6f8wsyaxd9v36pytvp48zckswvv9', |
||||
description: { |
||||
name: 'Alice', |
||||
identity: 'alice', |
||||
website: 'alice.harmony.one', |
||||
securityContact: 'Bob', |
||||
details: "Don't mess with me!!!", |
||||
}, |
||||
commissionRate: { |
||||
rate: '0.1', |
||||
maxRate: '0.9', |
||||
maxChangeRate: '0.05', |
||||
}, |
||||
minSelfDelegation: '0xa', |
||||
maxTotalDelegation: '0x0bb8', |
||||
slotPubKeys: [ |
||||
'0xb9486167ab9087ab818dc4ce026edb5bf216863364c32e42df2af03c5ced1ad181e7d12f0e6dd5307a73b62247608611', |
||||
], |
||||
amount: '0x64', |
||||
}) |
||||
.setTxParams({ |
||||
nonce: '0x2', |
||||
gasPrice: '0x', |
||||
gasLimit: '0x64', |
||||
chainId: 0, |
||||
}) |
||||
.build(); |
||||
|
||||
stakingTxn |
||||
.sendTransaction() |
||||
.then(([stakingTxn, res]) => { |
||||
console.log(res); |
||||
}) |
||||
.catch((err) => { |
||||
console.log(err); |
||||
}); |
||||
|
||||
// const delegateMsg = Delegate({
|
||||
// delegatorAddress: 'one1a0x3d6xpmr6f8wsyaxd9v36pytvp48zckswvv9',
|
||||
// validatorAddress: 'one1a0x3d6xpmr6f8wsyaxd9v36pytvp48zckswvv9',
|
||||
// amount: '0xa',
|
||||
// });
|
||||
|
||||
// const stakingTxn = StakingTransaction({
|
||||
// directive: '0x2',
|
||||
// stakeMsg: delegateMsg,
|
||||
// nonce: '0x2',
|
||||
// gasPrice: '0x',
|
||||
// gasLimit: '0x64',
|
||||
// chainId: 0,
|
||||
// from: 'one1a0x3d6xpmr6f8wsyaxd9v36pytvp48zckswvv9',
|
||||
// });
|
||||
|
||||
// stakingTxn
|
||||
// .sendTransaction()
|
||||
// .then((stakingTxn, res) => {
|
||||
// console.log(res);
|
||||
// })
|
||||
// .catch((err) => {
|
||||
// console.log(err);
|
||||
// });
|
@ -1,172 +0,0 @@ |
||||
const { Harmony } = require('@harmony-js/core'); |
||||
const { ChainID, ChainType } = require('@harmony-js/utils'); |
||||
const { Delegate, StakingTransaction, StakingFactory } = require('@harmony-js/staking'); //../packages/harmony-staking
|
||||
const { TxStatus } = require('@harmony-js/transaction'); |
||||
|
||||
const LOCALNET = `http://localhost:9500`; |
||||
|
||||
// 1. initialize the Harmony instance
|
||||
|
||||
const harmony = new Harmony( |
||||
// rpc url
|
||||
LOCALNET, |
||||
{ |
||||
// chainType set to Harmony
|
||||
chainType: ChainType.Harmony, |
||||
// chainType set to HmyLocal
|
||||
chainId: ChainID.HmyLocal, |
||||
}, |
||||
); |
||||
|
||||
// 2. get wallet ready
|
||||
|
||||
// one1a2rhuaqjcvfu69met9sque2l3w5v9z6qcdcz65
|
||||
// surge welcome lion goose gate consider taste injury health march debris kick
|
||||
|
||||
// add privateKey to wallet
|
||||
const private = '63e35b761e9df0d50ddcdaa8e33c235b60c991bfed22925a12768b0c08ef822f'; |
||||
// one1pdv9lrdwl0rg5vglh4xtyrv3wjk3wsqket7zxy
|
||||
const sender = harmony.wallet.addByPrivateKey(private); |
||||
console.log(sender.address); |
||||
// const phrase =
|
||||
// 'genius cable radar memory high catch blossom correct middle wish gentle
|
||||
// fiscal';
|
||||
|
||||
// one1a2rhuaqjcvfu69met9sque2l3w5v9z6qcdcz65
|
||||
// surge welcome lion goose gate consider taste injury health march debris kick
|
||||
|
||||
// add privateKey to wallet
|
||||
// const sender = harmony.wallet.addByMnemonic(phrase);
|
||||
// let r =
|
||||
// '0xf8f180f8a4940b585f8daefbc68a311fbd4cb20d9174ad174016f83885416c69636585616c69636591616c6963652e6861726d6f6e792e6f6e6583426f6295446f6e2774206d6573732077697468206d65212121ddc988016345785d8a0000c9880c7d713b49da0000c887b1a2bc2ec500000a820bb8f1b0b9486167ab9087ab818dc4ce026edb5bf216863364c32e42df2af03c5ced1ad181e7d12f0e6dd5307a73b6224760861164008080830927c028a064b1b835f5b70a72228920db24e44c0a57d954c1d3dcac3b33c79d9593f96191a05577fd05064a37043a33ff7febb67ab126a8e1f0b67c92b7cab793a87ddf2c82';
|
||||
|
||||
// const delegateMsg = new Delegate(
|
||||
// 'one1pf75h0t4am90z8uv3y0dgunfqp4lj8wr3t5rsp', // from delegate command.
|
||||
// 'one1pdv9lrdwl0rg5vglh4xtyrv3wjk3wsqket7zxy', // fd416cb87dcf8ed187e85545d7734a192fc8e976f5b540e9e21e896ec2bc25c3
|
||||
// '0xde0b6b3a7640000', // 0x56BC75E2D63100000
|
||||
// );
|
||||
|
||||
// // one12fuf7x9rgtdgqg7vgq0962c556m3p7afsxgvll;
|
||||
|
||||
// const stakingTxn = new StakingTransaction(
|
||||
// '0x2',
|
||||
// delegateMsg,
|
||||
// '0x2',
|
||||
// '0x',
|
||||
// '0x0927c0',
|
||||
// ChainID.HmyLocal,
|
||||
// );
|
||||
|
||||
const stakingTxn = harmony.stakings |
||||
.delegate({ |
||||
delegatorAddress: 'one1pf75h0t4am90z8uv3y0dgunfqp4lj8wr3t5rsp', |
||||
validatorAddress: 'one1pdv9lrdwl0rg5vglh4xtyrv3wjk3wsqket7zxy', |
||||
amount: '0xde0b6b3a7640000', |
||||
}) |
||||
.setTxParams({ nonce: '0x2', gasPrice: '0x', gasLimit: '0x0927c0', chainId: ChainID.HmyLocal }) |
||||
.build(); |
||||
|
||||
// 3. get sharding info
|
||||
async function setSharding() { |
||||
// Harmony is a sharded blockchain, each endpoint have sharding structure,
|
||||
// However sharding structure is different between mainnet, testnet and local
|
||||
// testnet We need to get sharding info before doing cross-shard transaction
|
||||
const res = await harmony.blockchain.getShardingStructure(); |
||||
harmony.shardingStructures(res.result); |
||||
} |
||||
|
||||
async function execute() { |
||||
await setSharding(); |
||||
|
||||
const signedTxn = await harmony.wallet.signStaking(stakingTxn); |
||||
signedTxn |
||||
.observed() |
||||
.on('transactionHash', (txnHash) => { |
||||
console.log(''); |
||||
console.log('--- hash ---'); |
||||
console.log(''); |
||||
console.log(txnHash); |
||||
console.log(''); |
||||
}) |
||||
.on('receipt', (receipt) => { |
||||
console.log(''); |
||||
console.log('--- receipt ---'); |
||||
console.log(''); |
||||
console.log(receipt); |
||||
console.log(''); |
||||
}) |
||||
.on('cxReceipt', (receipt) => { |
||||
console.log(''); |
||||
console.log('--- cxReceipt ---'); |
||||
console.log(''); |
||||
console.log(receipt); |
||||
console.log(''); |
||||
}) |
||||
.on('error', (error) => { |
||||
console.log(''); |
||||
console.log('--- error ---'); |
||||
console.log(''); |
||||
console.log(error); |
||||
console.log(''); |
||||
}); |
||||
|
||||
// console.log(signedTxn);
|
||||
|
||||
const [sentTxn, txnHash] = await signedTxn.sendTransaction(); |
||||
// signedTxn.sendTransaction()
|
||||
// .then(res => {
|
||||
// console.log(res);
|
||||
// })
|
||||
// .catch(err => {
|
||||
// console.log(err);
|
||||
// });
|
||||
|
||||
// to confirm the result if it is already there
|
||||
// console.log(txnHash);
|
||||
console.log(sentTxn); |
||||
|
||||
const confiremdTxn = await sentTxn.confirm(txnHash); |
||||
|
||||
// if the transactino is cross-shard transaction
|
||||
if (confiremdTxn.isConfirmed()) { |
||||
console.log('--- Result ---'); |
||||
console.log(''); |
||||
console.log('Normal transaction'); |
||||
console.log(`${txnHash} is confirmed`); |
||||
console.log(''); |
||||
process.exit(); |
||||
} |
||||
// if (confiremdTxn.isConfirmed() && confiremdTxn.isCxConfirmed()) {
|
||||
// console.log('--- Result ---');
|
||||
// console.log('');
|
||||
// console.log('Cross-Shard transaction');
|
||||
// console.log(`${txnHash} is confirmed`);
|
||||
// console.log('');
|
||||
// process.exit();
|
||||
// }
|
||||
} |
||||
execute(); |
||||
// const delegateMsg = Delegate({
|
||||
// delegatorAddress: 'one1a0x3d6xpmr6f8wsyaxd9v36pytvp48zckswvv9',
|
||||
// validatorAddress: 'one1a0x3d6xpmr6f8wsyaxd9v36pytvp48zckswvv9',
|
||||
// amount: '0xa',
|
||||
// });
|
||||
|
||||
// const stakingTxn = StakingTransaction({
|
||||
// directive: '0x2',
|
||||
// stakeMsg: delegateMsg,
|
||||
// nonce: '0x2',
|
||||
// gasPrice: '0x',
|
||||
// gasLimit: '0x64',
|
||||
// chainId: 0,
|
||||
// from: 'one1a0x3d6xpmr6f8wsyaxd9v36pytvp48zckswvv9',
|
||||
// });
|
||||
|
||||
// stakingTxn
|
||||
// .sendTransaction()
|
||||
// .then((stakingTxn, res) => {
|
||||
// console.log(res);
|
||||
// })
|
||||
// .catch((err) => {
|
||||
// console.log(err);
|
||||
// });
|
@ -1,74 +0,0 @@ |
||||
const { Harmony } = require('@harmony-js/core'); |
||||
const { ChainID, ChainType } = require('@harmony-js/utils'); |
||||
const { StakingFactory } = require('@harmony-js/staking'); |
||||
|
||||
const harmony = new Harmony('http://localhost:9500', { |
||||
chainId: ChainID.HmyLocal, |
||||
chainType: ChainType.Harmony, |
||||
}); |
||||
|
||||
const createMsg = { |
||||
validatorAddress: 'one1a0x3d6xpmr6f8wsyaxd9v36pytvp48zckswvv9', |
||||
description: { |
||||
name: 'Alice', |
||||
identity: 'alice', |
||||
website: 'alice.harmony.one', |
||||
securityContact: 'Bob', |
||||
details: "Don't mess with me!!!", |
||||
}, |
||||
commissionRate: { |
||||
rate: '0.1', |
||||
maxRate: '0.9', |
||||
maxChangeRate: '0.05', |
||||
}, |
||||
minSelfDelegation: '0xa', |
||||
maxTotalDelegation: '0x0bb8', |
||||
slotPubKeys: [ |
||||
'0xb9486167ab9087ab818dc4ce026edb5bf216863364c32e42df2af03c5ced1ad181e7d12f0e6dd5307a73b62247608611', |
||||
], |
||||
amount: '0x64', |
||||
}; |
||||
|
||||
const stakingTxn = harmony.stakings |
||||
.createValidator(createMsg) |
||||
.setTxParams({ |
||||
nonce: '0x2', |
||||
gasPrice: '0x', |
||||
gasLimit: '0x64', |
||||
chainId: 0, |
||||
}) |
||||
.build(); |
||||
|
||||
stakingTxn |
||||
.sendTransaction() |
||||
.then(([stakingTxn, res]) => { |
||||
console.log(res); |
||||
}) |
||||
.catch((err) => { |
||||
console.log(err); |
||||
}); |
||||
|
||||
// const delegateMsg = Delegate({
|
||||
// delegatorAddress: 'one1a0x3d6xpmr6f8wsyaxd9v36pytvp48zckswvv9',
|
||||
// validatorAddress: 'one1a0x3d6xpmr6f8wsyaxd9v36pytvp48zckswvv9',
|
||||
// amount: '0xa',
|
||||
// });
|
||||
|
||||
// const stakingTxn = StakingTransaction({
|
||||
// directive: '0x2',
|
||||
// stakeMsg: delegateMsg,
|
||||
// nonce: '0x2',
|
||||
// gasPrice: '0x',
|
||||
// gasLimit: '0x64',
|
||||
// chainId: 0,
|
||||
// from: 'one1a0x3d6xpmr6f8wsyaxd9v36pytvp48zckswvv9',
|
||||
// });
|
||||
|
||||
// stakingTxn
|
||||
// .sendTransaction()
|
||||
// .then((stakingTxn, res) => {
|
||||
// console.log(res);
|
||||
// })
|
||||
// .catch((err) => {
|
||||
// console.log(err);
|
||||
// });
|
@ -1,177 +0,0 @@ |
||||
const { Harmony } = require('@harmony-js/core'); |
||||
const { ChainID, ChainType } = require('@harmony-js/utils'); |
||||
const { |
||||
Description, |
||||
Decimal, |
||||
CommissionRate, |
||||
StakingTransaction, |
||||
CreateValidator, |
||||
} = require('@harmony-js/staking'); //../packages/harmony-staking
|
||||
const { TxStatus } = require('@harmony-js/transaction'); |
||||
|
||||
const LOCALNET = `http://localhost:9500`; |
||||
|
||||
// 1. initialize the Harmony instance
|
||||
|
||||
const harmony = new Harmony( |
||||
// rpc url
|
||||
LOCALNET, |
||||
{ |
||||
// chainType set to Harmony
|
||||
chainType: ChainType.Harmony, |
||||
// chainType set to HmyLocal
|
||||
chainId: ChainID.HmyLocal, |
||||
}, |
||||
); |
||||
|
||||
// 2. get wallet ready
|
||||
|
||||
// one1a2rhuaqjcvfu69met9sque2l3w5v9z6qcdcz65
|
||||
// surge welcome lion goose gate consider taste injury health march debris kick
|
||||
|
||||
// add privateKey to wallet
|
||||
const private = 'fd416cb87dcf8ed187e85545d7734a192fc8e976f5b540e9e21e896ec2bc25c3'; |
||||
const sender = harmony.wallet.addByPrivateKey(private); |
||||
// const phrase =
|
||||
// 'genius cable radar memory high catch blossom correct middle wish gentle
|
||||
// fiscal';
|
||||
|
||||
// one1a2rhuaqjcvfu69met9sque2l3w5v9z6qcdcz65
|
||||
// surge welcome lion goose gate consider taste injury health march debris kick
|
||||
|
||||
// add privateKey to wallet
|
||||
// const sender = harmony.wallet.addByMnemonic(phrase);
|
||||
|
||||
const stakingTxn = harmony.stakings |
||||
.createValidator({ |
||||
validatorAddress: 'one1pdv9lrdwl0rg5vglh4xtyrv3wjk3wsqket7zxy', |
||||
description: { |
||||
name: 'Alice', |
||||
identity: 'alice', |
||||
website: 'alice.harmony.one', |
||||
securityContact: 'Bob', |
||||
details: "Don't mess with me!!", |
||||
}, |
||||
commissionRate: { rate: '0.1', maxRate: '0.9', maxChangeRate: '0.05' }, |
||||
minSelfDelegation: '0x8AC7230489E80000', |
||||
maxTotalDelegation: '0xA2A15D09519BE00000', |
||||
slotPubKeys: [ |
||||
'0xb9486167ab9087ab818dc4ce026edb5bf216863364c32e42df2af03c5ced1ad181e7d12f0e6dd5307a73b62247608611', |
||||
], |
||||
amount: '0x56BC75E2D63100000', |
||||
}) |
||||
.setTxParams({ |
||||
nonce: '0x2', |
||||
gasPrice: '0x', |
||||
gasLimit: '0x0927c0', |
||||
chainId: ChainID.HmyLocal, |
||||
}) |
||||
.build(); |
||||
|
||||
// 3. get sharding info
|
||||
async function setSharding() { |
||||
// Harmony is a sharded blockchain, each endpoint have sharding structure,
|
||||
// However sharding structure is different between mainnet, testnet and local
|
||||
// testnet We need to get sharding info before doing cross-shard transaction
|
||||
const res = await harmony.blockchain.getShardingStructure(); |
||||
harmony.shardingStructures(res.result); |
||||
} |
||||
|
||||
async function execute() { |
||||
await setSharding(); |
||||
|
||||
const signedTxn = await harmony.wallet.signStaking(stakingTxn); |
||||
signedTxn |
||||
.observed() |
||||
.on('transactionHash', (txnHash) => { |
||||
console.log(''); |
||||
console.log('--- hash ---'); |
||||
console.log(''); |
||||
console.log(txnHash); |
||||
console.log(''); |
||||
}) |
||||
.on('receipt', (receipt) => { |
||||
console.log(''); |
||||
console.log('--- receipt ---'); |
||||
console.log(''); |
||||
console.log(receipt); |
||||
console.log(''); |
||||
}) |
||||
.on('cxReceipt', (receipt) => { |
||||
console.log(''); |
||||
console.log('--- cxReceipt ---'); |
||||
console.log(''); |
||||
console.log(receipt); |
||||
console.log(''); |
||||
}) |
||||
.on('error', (error) => { |
||||
console.log(''); |
||||
console.log('--- error ---'); |
||||
console.log(''); |
||||
console.log(error); |
||||
console.log(''); |
||||
}); |
||||
|
||||
// console.log(signedTxn);
|
||||
|
||||
const [sentTxn, txnHash] = await signedTxn.sendTransaction(); |
||||
// signedTxn
|
||||
// .sendTransaction()
|
||||
// .then((res) => {
|
||||
// console.log(res);
|
||||
// })
|
||||
// .catch((err) => {
|
||||
// console.log(err);
|
||||
// });
|
||||
|
||||
// to confirm the result if it is already there
|
||||
console.log(txnHash); |
||||
console.log(sentTxn); |
||||
|
||||
const confiremdTxn = await sentTxn.confirm(txnHash); |
||||
|
||||
// if the transactino is cross-shard transaction
|
||||
// if (!confiremdTxn.isCrossShard()) {
|
||||
if (confiremdTxn.isConfirmed()) { |
||||
console.log('--- Result ---'); |
||||
console.log(''); |
||||
console.log('Staking transaction'); |
||||
console.log(`${txnHash} is confirmed`); |
||||
console.log(''); |
||||
process.exit(); |
||||
} |
||||
// }
|
||||
// if (confiremdTxn.isConfirmed() && confiremdTxn.isCxConfirmed()) {
|
||||
// console.log('--- Result ---');
|
||||
// console.log('');
|
||||
// console.log('Cross-Shard transaction');
|
||||
// console.log(`${txnHash} is confirmed`);
|
||||
// console.log('');
|
||||
// process.exit();
|
||||
// }
|
||||
} |
||||
execute(); |
||||
// const delegateMsg = Delegate({
|
||||
// delegatorAddress: 'one1a0x3d6xpmr6f8wsyaxd9v36pytvp48zckswvv9',
|
||||
// validatorAddress: 'one1a0x3d6xpmr6f8wsyaxd9v36pytvp48zckswvv9',
|
||||
// amount: '0xa',
|
||||
// });
|
||||
|
||||
// const stakingTxn = StakingTransaction({
|
||||
// directive: '0x2',
|
||||
// stakeMsg: delegateMsg,
|
||||
// nonce: '0x2',
|
||||
// gasPrice: '0x',
|
||||
// gasLimit: '0x64',
|
||||
// chainId: 0,
|
||||
// from: 'one1a0x3d6xpmr6f8wsyaxd9v36pytvp48zckswvv9',
|
||||
// });
|
||||
|
||||
// stakingTxn
|
||||
// .sendTransaction()
|
||||
// .then((stakingTxn, res) => {
|
||||
// console.log(res);
|
||||
// })
|
||||
// .catch((err) => {
|
||||
// console.log(err);
|
||||
// });
|
@ -1,173 +0,0 @@ |
||||
const { Harmony } = require('@harmony-js/core'); |
||||
const { ChainID, ChainType } = require('@harmony-js/utils'); |
||||
const { Undelegate, StakingTransaction, StakingFactory } = require('@harmony-js/staking'); //../packages/harmony-staking
|
||||
const { TxStatus } = require('@harmony-js/transaction'); |
||||
|
||||
const LOCALNET = `http://localhost:9500`; |
||||
|
||||
// 1. initialize the Harmony instance
|
||||
|
||||
const harmony = new Harmony( |
||||
// rpc url
|
||||
LOCALNET, |
||||
{ |
||||
// chainType set to Harmony
|
||||
chainType: ChainType.Harmony, |
||||
// chainType set to HmyLocal
|
||||
chainId: ChainID.HmyLocal, |
||||
}, |
||||
); |
||||
|
||||
// 2. get wallet ready
|
||||
|
||||
// one1a2rhuaqjcvfu69met9sque2l3w5v9z6qcdcz65
|
||||
// surge welcome lion goose gate consider taste injury health march debris kick
|
||||
|
||||
// add privateKey to wallet
|
||||
const private = '63e35b761e9df0d50ddcdaa8e33c235b60c991bfed22925a12768b0c08ef822f'; |
||||
const sender = harmony.wallet.addByPrivateKey(private); |
||||
// const phrase =
|
||||
// 'genius cable radar memory high catch blossom correct middle wish gentle
|
||||
// fiscal';
|
||||
|
||||
// one1a2rhuaqjcvfu69met9sque2l3w5v9z6qcdcz65
|
||||
// surge welcome lion goose gate consider taste injury health march debris kick
|
||||
|
||||
// add privateKey to wallet
|
||||
// const sender = harmony.wallet.addByMnemonic(phrase);
|
||||
// let r =
|
||||
// '0xf8f180f8a4940b585f8daefbc68a311fbd4cb20d9174ad174016f83885416c69636585616c69636591616c6963652e6861726d6f6e792e6f6e6583426f6295446f6e2774206d6573732077697468206d65212121ddc988016345785d8a0000c9880c7d713b49da0000c887b1a2bc2ec500000a820bb8f1b0b9486167ab9087ab818dc4ce026edb5bf216863364c32e42df2af03c5ced1ad181e7d12f0e6dd5307a73b6224760861164008080830927c028a064b1b835f5b70a72228920db24e44c0a57d954c1d3dcac3b33c79d9593f96191a05577fd05064a37043a33ff7febb67ab126a8e1f0b67c92b7cab793a87ddf2c82';
|
||||
|
||||
// const undelegateMsg = new Undelegate(
|
||||
// 'one1pf75h0t4am90z8uv3y0dgunfqp4lj8wr3t5rsp', // signed should match this
|
||||
// 'one1pdv9lrdwl0rg5vglh4xtyrv3wjk3wsqket7zxy',
|
||||
// '0x16345785d8a0000',
|
||||
// );
|
||||
|
||||
// const stakingTxn = new StakingTransaction(
|
||||
// '0x3',
|
||||
// undelegateMsg,
|
||||
// '0x2',
|
||||
// '0x',
|
||||
// '0x0927c0',
|
||||
// ChainID.HmyLocal,
|
||||
// );
|
||||
|
||||
const stakingTxn = harmony.stakings |
||||
.undelegate({ |
||||
delegatorAddress: 'one1pf75h0t4am90z8uv3y0dgunfqp4lj8wr3t5rsp', |
||||
validatorAddress: 'one1pdv9lrdwl0rg5vglh4xtyrv3wjk3wsqket7zxy', |
||||
amount: '0x16345785d8a0000', |
||||
}) |
||||
.setTxParams({ |
||||
nonce: '0x2', |
||||
gasPrice: '0x', |
||||
gasLimit: '0x0927c0', |
||||
chainId: ChainID.HmyLocal, |
||||
}) |
||||
.build(); |
||||
|
||||
// 3. get sharding info
|
||||
async function setSharding() { |
||||
// Harmony is a sharded blockchain, each endpoint have sharding structure,
|
||||
// However sharding structure is different between mainnet, testnet and local
|
||||
// testnet We need to get sharding info before doing cross-shard transaction
|
||||
const res = await harmony.blockchain.getShardingStructure(); |
||||
harmony.shardingStructures(res.result); |
||||
} |
||||
|
||||
async function execute() { |
||||
await setSharding(); |
||||
|
||||
const signedTxn = await harmony.wallet.signStaking(stakingTxn); |
||||
signedTxn |
||||
.observed() |
||||
.on('transactionHash', (txnHash) => { |
||||
console.log(''); |
||||
console.log('--- hash ---'); |
||||
console.log(''); |
||||
console.log(txnHash); |
||||
console.log(''); |
||||
}) |
||||
.on('receipt', (receipt) => { |
||||
console.log(''); |
||||
console.log('--- receipt ---'); |
||||
console.log(''); |
||||
console.log(receipt); |
||||
console.log(''); |
||||
}) |
||||
.on('cxReceipt', (receipt) => { |
||||
console.log(''); |
||||
console.log('--- cxReceipt ---'); |
||||
console.log(''); |
||||
console.log(receipt); |
||||
console.log(''); |
||||
}) |
||||
.on('error', (error) => { |
||||
console.log(''); |
||||
console.log('--- error ---'); |
||||
console.log(''); |
||||
console.log(error); |
||||
console.log(''); |
||||
}); |
||||
|
||||
// console.log(signedTxn);
|
||||
|
||||
const [sentTxn, txnHash] = await signedTxn.sendTransaction(); |
||||
// signedTxn.sendTransaction()
|
||||
// .then(res => {
|
||||
// console.log(res);
|
||||
// })
|
||||
// .catch(err => {
|
||||
// console.log(err);
|
||||
// });
|
||||
|
||||
// to confirm the result if it is already there
|
||||
// console.log(txnHash);
|
||||
console.log(sentTxn); |
||||
|
||||
const confiremdTxn = await sentTxn.confirm(txnHash); |
||||
|
||||
// if the transactino is cross-shard transaction
|
||||
if (confiremdTxn.isConfirmed()) { |
||||
console.log('--- Result ---'); |
||||
console.log(''); |
||||
console.log('Normal transaction'); |
||||
console.log(`${txnHash} is confirmed`); |
||||
console.log(''); |
||||
process.exit(); |
||||
} |
||||
// if (confiremdTxn.isConfirmed() && confiremdTxn.isCxConfirmed()) {
|
||||
// console.log('--- Result ---');
|
||||
// console.log('');
|
||||
// console.log('Cross-Shard transaction');
|
||||
// console.log(`${txnHash} is confirmed`);
|
||||
// console.log('');
|
||||
// process.exit();
|
||||
// }
|
||||
} |
||||
execute(); |
||||
// const delegateMsg = Delegate({
|
||||
// delegatorAddress: 'one1a0x3d6xpmr6f8wsyaxd9v36pytvp48zckswvv9',
|
||||
// validatorAddress: 'one1a0x3d6xpmr6f8wsyaxd9v36pytvp48zckswvv9',
|
||||
// amount: '0xa',
|
||||
// });
|
||||
|
||||
// const stakingTxn = StakingTransaction({
|
||||
// directive: '0x2',
|
||||
// stakeMsg: delegateMsg,
|
||||
// nonce: '0x2',
|
||||
// gasPrice: '0x',
|
||||
// gasLimit: '0x64',
|
||||
// chainId: 0,
|
||||
// from: 'one1a0x3d6xpmr6f8wsyaxd9v36pytvp48zckswvv9',
|
||||
// });
|
||||
|
||||
// stakingTxn
|
||||
// .sendTransaction()
|
||||
// .then((stakingTxn, res) => {
|
||||
// console.log(res);
|
||||
// })
|
||||
// .catch((err) => {
|
||||
// console.log(err);
|
||||
// });
|
@ -1,31 +0,0 @@ |
||||
const { Harmony } = require('@harmony-js/core'); |
||||
const { ChainID, ChainType } = require('@harmony-js/utils'); |
||||
const { encryptPhrase, decryptPhrase } = require('@harmony-js/crypto'); |
||||
|
||||
const harmony = new Harmony('http://localhost:9500', { chainId: 2, chainType: 'hmy' }); |
||||
const myPhrase = harmony.wallet.newMnemonic(); |
||||
const pwd = '1234'; |
||||
|
||||
async function encryptThePhrase(phrase, pass) { |
||||
const result = await encryptPhrase(phrase, pass); |
||||
return result; |
||||
} |
||||
|
||||
async function decryptThePhrase(keystore, pass) { |
||||
const result = await decryptPhrase(keystore, pass); |
||||
return result; |
||||
} |
||||
|
||||
async function phraseKeyStore() { |
||||
const keyStore = await encryptThePhrase(myPhrase, pwd); |
||||
const recoveredPhrase = await decryptThePhrase(JSON.parse(keyStore), pwd); |
||||
return { myPhrase, keyStore, recoveredPhrase }; |
||||
} |
||||
|
||||
phraseKeyStore().then((result) => { |
||||
const { myPhrase, keyStore, recoveredPhrase } = result; |
||||
|
||||
harmony.wallet.addByMnemonic(myPhrase); |
||||
console.log({ myPhrase, keyStore, recoveredPhrase }); |
||||
console.log(harmony.wallet); |
||||
}); |
@ -1,40 +0,0 @@ |
||||
const { Harmony } = require('@harmony-js/core'); |
||||
const { ChainID, ChainType } = require('@harmony-js/utils'); |
||||
const { |
||||
randomBytes, |
||||
generatePrivateKey, |
||||
getAddress, |
||||
getAddressFromPrivateKey, |
||||
encryptPhrase, |
||||
decryptPhrase, |
||||
} = require('@harmony-js/crypto'); |
||||
|
||||
const harmony = new Harmony('http://localhost:9500', { chainId: 2, chainType: 'hmy' }); |
||||
const myPhrase = harmony.wallet.newMnemonic(); |
||||
const pwd = '1234'; |
||||
|
||||
async function encryptThePhrase(phrase, pass) { |
||||
const result = await encryptPhrase(phrase, pass); |
||||
return result; |
||||
} |
||||
|
||||
async function decryptThePhrase(keystore, pass) { |
||||
const result = await decryptPhrase(keystore, pass); |
||||
return result; |
||||
} |
||||
|
||||
async function phraseKeyStore() { |
||||
const keyStore = await encryptThePhrase(myPhrase, pwd); |
||||
const recoveredPhrase = await decryptThePhrase(JSON.parse(keyStore), pwd); |
||||
return { myPhrase, keyStore, recoveredPhrase }; |
||||
} |
||||
|
||||
phraseKeyStore().then((result) => { |
||||
const { myPhrase, keyStore, recoveredPhrase } = result; |
||||
|
||||
const anotherPhrase = 'wall public vague under poem acid jaguar describe net scene sponsor neck'; |
||||
harmony.wallet.addByMnemonic(myPhrase); |
||||
harmony.wallet.addByMnemonic(anotherPhrase); |
||||
console.log({ myPhrase, keyStore, recoveredPhrase }); |
||||
console.log(harmony.wallet); |
||||
}); |
@ -1,153 +0,0 @@ |
||||
// import or require Harmony class
|
||||
const { Harmony } = require('@harmony-js/core'); |
||||
|
||||
// import or require settings
|
||||
const { ChainID, ChainType } = require('@harmony-js/utils'); |
||||
|
||||
const URL_TESTNET = `https://api.s0.b.hmny.io`; |
||||
const URL_MAINNET = `https://api.s0.t.hmny.io`; |
||||
const URL_PANGAEA = 'https://api.s0.pga.hmny.io'; |
||||
|
||||
// 1. initialize the Harmony instance
|
||||
|
||||
const harmony = new Harmony( |
||||
// rpc url
|
||||
URL_PANGAEA, |
||||
{ |
||||
// chainType set to Harmony
|
||||
chainType: ChainType.Harmony, |
||||
// chainType set to HmyLocal
|
||||
chainId: ChainID.HmyPangaea, |
||||
}, |
||||
); |
||||
|
||||
// 2. get wallet ready
|
||||
// one18n8e7472pg5fqvcfcr5hg0npquha24wsxmjheg
|
||||
const phrase = 'genius cable radar memory high catch blossom correct middle wish gentle fiscal'; |
||||
// const phrase =
|
||||
// 'resemble rent deposit unique garment ripple burst negative else decorate menu theme';
|
||||
|
||||
// one1a2rhuaqjcvfu69met9sque2l3w5v9z6qcdcz65
|
||||
// surge welcome lion goose gate consider taste injury health march debris kick
|
||||
|
||||
// add privateKey to wallet
|
||||
|
||||
const privateKey = '63e35b761e9df0d50ddcdaa8e33c235b60c991bfed22925a12768b0c08ef822f'; |
||||
|
||||
const sender = harmony.wallet.addByMnemonic(phrase); |
||||
const sender2 = harmony.wallet.addByPrivateKey(privateKey); |
||||
|
||||
harmony.wallet.setSigner(sender2.address); |
||||
|
||||
console.log('sender2Address is : ', sender2.bech32Address); |
||||
|
||||
// 3. get sharding info
|
||||
async function setSharding() { |
||||
// Harmony is a sharded blockchain, each endpoint have sharding structure,
|
||||
// However sharding structure is different between mainnet, testnet and local testnet
|
||||
// We need to get sharding info before doing cross-shard transaction
|
||||
const res = await harmony.blockchain.getShardingStructure(); |
||||
|
||||
harmony.shardingStructures(res.result); |
||||
} |
||||
|
||||
// 4. get transaction payload ready
|
||||
|
||||
async function transfer(receiver) { |
||||
// run set sharding first, if you want to make a cross-shard transaction
|
||||
await setSharding(); |
||||
|
||||
//1e18
|
||||
const txn = harmony.transactions.newTx({ |
||||
// token send to
|
||||
to: receiver, |
||||
// amount to send
|
||||
value: '100000000', |
||||
// gas limit, you can use string
|
||||
gasLimit: '210000', |
||||
// send token from shardID
|
||||
shardID: 0, |
||||
// send token to toShardID
|
||||
toShardID: 1, |
||||
// gas Price, you can use Unit class, and use Gwei, then remember to use toWei(), which will be transformed to BN
|
||||
gasPrice: new harmony.utils.Unit('10').asGwei().toWei(), |
||||
}); |
||||
|
||||
// sign the transaction use wallet;
|
||||
|
||||
// This will happen at the chrome extension.
|
||||
const signedTxn = await harmony.wallet.signTransaction(txn); |
||||
|
||||
// Now you can use `Transaction.observed()` to listen events
|
||||
|
||||
// Frontend received back the signedTxn and do the followings to Send transaction.
|
||||
signedTxn |
||||
.observed() |
||||
.on('transactionHash', (txnHash) => { |
||||
console.log(''); |
||||
console.log('--- hash ---'); |
||||
console.log(''); |
||||
console.log(txnHash); |
||||
console.log(''); |
||||
}) |
||||
.on('receipt', (receipt) => { |
||||
console.log(''); |
||||
console.log('--- receipt ---'); |
||||
console.log(''); |
||||
console.log(receipt); |
||||
console.log(''); |
||||
}) |
||||
.on('cxReceipt', (receipt) => { |
||||
console.log(''); |
||||
console.log('--- cxReceipt ---'); |
||||
console.log(''); |
||||
console.log(receipt); |
||||
console.log(''); |
||||
}) |
||||
.on('error', (error) => { |
||||
console.log(''); |
||||
console.log('--- error ---'); |
||||
console.log(''); |
||||
console.log(error); |
||||
console.log(''); |
||||
}); |
||||
|
||||
// send the txn, get [Transaction, transactionHash] as result
|
||||
|
||||
const [sentTxn, txnHash] = await signedTxn.sendTransaction(); |
||||
|
||||
// to confirm the result if it is already there
|
||||
|
||||
const confiremdTxn = await sentTxn.confirm(txnHash); |
||||
|
||||
// if the transactino is cross-shard transaction
|
||||
if (!confiremdTxn.isCrossShard()) { |
||||
if (confiremdTxn.isConfirmed()) { |
||||
console.log('--- Result ---'); |
||||
console.log(''); |
||||
console.log('Normal transaction'); |
||||
console.log(`${txnHash} is confirmed`); |
||||
console.log(''); |
||||
console.log('please see detail in explorer:'); |
||||
console.log(''); |
||||
console.log('https://explorer.harmony.one/#/tx/' + txnHash); |
||||
console.log(''); |
||||
process.exit(); |
||||
} |
||||
} |
||||
if (confiremdTxn.isConfirmed() && confiremdTxn.isCxConfirmed()) { |
||||
console.log('--- Result ---'); |
||||
console.log(''); |
||||
console.log('Cross-Shard transaction'); |
||||
console.log(`${txnHash} is confirmed`); |
||||
console.log(''); |
||||
console.log('please see detail in explorer:'); |
||||
console.log(''); |
||||
console.log('https://explorer.harmony.one/#/tx/' + txnHash); |
||||
console.log(''); |
||||
process.exit(); |
||||
} |
||||
} |
||||
|
||||
// sending from one18n8e7472pg5fqvcfcr5hg0npquha24wsxmjheg to one1a2rhuaqjcvfu69met9sque2l3w5v9z6qcdcz65
|
||||
(async () => await transfer('one1pf75h0t4am90z8uv3y0dgunfqp4lj8wr3t5rsp'))(); |
@ -1,151 +0,0 @@ |
||||
// import or require Harmony class
|
||||
const { Harmony } = require('@harmony-js/core'); |
||||
|
||||
// import or require settings
|
||||
const { ChainID, ChainType } = require('@harmony-js/utils'); |
||||
|
||||
// const URL_TESTNET = `https://api.s0.pga.hmny.io`;
|
||||
const URL_MAINNET = `https://api.s0.t.hmny.io`; |
||||
// const LOCAL_TESTNET = `http://localhost:9500`;
|
||||
const DEVNET = 'https://api.s0.pga.hmny.io'; |
||||
// 1. initialize the Harmony instance
|
||||
|
||||
const harmony = new Harmony( |
||||
// rpc url
|
||||
DEVNET, |
||||
{ |
||||
// chainType set to Harmony
|
||||
chainType: ChainType.Harmony, |
||||
// chainType set to HmyLocal
|
||||
chainId: ChainID.HmyPangaea, |
||||
}, |
||||
); |
||||
|
||||
// 2. get wallet ready
|
||||
// one18n8e7472pg5fqvcfcr5hg0npquha24wsxmjheg;
|
||||
const phrase = 'genius cable radar memory high catch blossom correct middle wish gentle fiscal'; |
||||
|
||||
// one1a2rhuaqjcvfu69met9sque2l3w5v9z6qcdcz65
|
||||
// surge welcome lion goose gate consider taste injury health march debris kick
|
||||
|
||||
// add privateKey to wallet
|
||||
// const sender = harmony.wallet.addByMnemonic(phrase);
|
||||
|
||||
// add privateKey to wallet
|
||||
const private = '63e35b761e9df0d50ddcdaa8e33c235b60c991bfed22925a12768b0c08ef822f'; |
||||
// one1pdv9lrdwl0rg5vglh4xtyrv3wjk3wsqket7zxy
|
||||
const sender = harmony.wallet.addByPrivateKey(private); |
||||
|
||||
// const sender = harmony.wallet.addByPrivateKey(
|
||||
// 'fd416cb87dcf8ed187e85545d7734a192fc8e976f5b540e9e21e896ec2bc25c3',
|
||||
// );
|
||||
|
||||
// 3. get sharding info
|
||||
async function setSharding() { |
||||
// Harmony is a sharded blockchain, each endpoint have sharding structure,
|
||||
// However sharding structure is different between mainnet, testnet and local testnet
|
||||
// We need to get sharding info before doing cross-shard transaction
|
||||
const res = await harmony.blockchain.getShardingStructure(); |
||||
harmony.shardingStructures(res.result); |
||||
} |
||||
|
||||
// 4. get transaction payload ready
|
||||
|
||||
async function transfer(receiver) { |
||||
// run set sharding first, if you want to make a cross-shard transaction
|
||||
await setSharding(); |
||||
|
||||
//1e18
|
||||
const txn = harmony.transactions.newTx({ |
||||
// token send to
|
||||
to: receiver, |
||||
// amount to send
|
||||
value: '100000000000000000', |
||||
// gas limit, you can use string
|
||||
gasLimit: '210000', |
||||
// send token from shardID
|
||||
shardID: 0, |
||||
// send token to toShardID
|
||||
toShardID: 0, |
||||
// gas Price, you can use Unit class, and use Gwei, then remember to use toWei(), which will be transformed to BN
|
||||
gasPrice: new harmony.utils.Unit('100').asGwei().toWei(), |
||||
}); |
||||
|
||||
// sign the transaction use wallet;
|
||||
|
||||
// This will happen at the chrome extension.
|
||||
const signedTxn = await harmony.wallet.signTransaction(txn); |
||||
|
||||
// Now you can use `Transaction.observed()` to listen events
|
||||
|
||||
// Frontend received back the signedTxn and do the followings to Send transaction.
|
||||
signedTxn |
||||
.observed() |
||||
.on('transactionHash', (txnHash) => { |
||||
console.log(''); |
||||
console.log('--- hash ---'); |
||||
console.log(''); |
||||
console.log(txnHash); |
||||
console.log(''); |
||||
}) |
||||
.on('receipt', (receipt) => { |
||||
console.log(''); |
||||
console.log('--- receipt ---'); |
||||
console.log(''); |
||||
console.log(receipt); |
||||
console.log(''); |
||||
}) |
||||
.on('cxReceipt', (receipt) => { |
||||
console.log(''); |
||||
console.log('--- cxReceipt ---'); |
||||
console.log(''); |
||||
console.log(receipt); |
||||
console.log(''); |
||||
}) |
||||
.on('error', (error) => { |
||||
console.log(''); |
||||
console.log('--- error ---'); |
||||
console.log(''); |
||||
console.log(error); |
||||
console.log(''); |
||||
}); |
||||
|
||||
// send the txn, get [Transaction, transactionHash] as result
|
||||
|
||||
const [sentTxn, txnHash] = await signedTxn.sendTransaction(); |
||||
|
||||
// to confirm the result if it is already there
|
||||
|
||||
const confiremdTxn = await sentTxn.confirm(txnHash); |
||||
|
||||
// if the transactino is cross-shard transaction
|
||||
// if (!confiremdTxn.isCrossShard()) {
|
||||
if (confiremdTxn.isConfirmed()) { |
||||
console.log('--- Result ---'); |
||||
console.log(''); |
||||
console.log('Normal transaction'); |
||||
console.log(`${txnHash} is confirmed`); |
||||
console.log(''); |
||||
console.log('please see detail in explorer:'); |
||||
console.log(''); |
||||
console.log('https://explorer.harmony.one/#/tx/' + txnHash); |
||||
console.log(''); |
||||
process.exit(); |
||||
} |
||||
// }
|
||||
if (confiremdTxn.isConfirmed() && confiremdTxn.isCxConfirmed()) { |
||||
console.log('--- Result ---'); |
||||
console.log(''); |
||||
console.log('Cross-Shard transaction'); |
||||
console.log(`${txnHash} is confirmed`); |
||||
console.log(''); |
||||
console.log('please see detail in explorer:'); |
||||
console.log(''); |
||||
console.log('https://explorer.harmony.one/#/tx/' + txnHash); |
||||
console.log(''); |
||||
process.exit(); |
||||
} |
||||
} |
||||
|
||||
// sending from one18n8e7472pg5fqvcfcr5hg0npquha24wsxmjheg to one1a2rhuaqjcvfu69met9sque2l3w5v9z6qcdcz65
|
||||
(async () => await transfer('one1pdv9lrdwl0rg5vglh4xtyrv3wjk3wsqket7zxy'))(); |
@ -1,137 +0,0 @@ |
||||
// import or require Harmony class
|
||||
const { Harmony } = require('@harmony-js/core'); |
||||
|
||||
// import or require settings
|
||||
const { ChainID, ChainType } = require('@harmony-js/utils'); |
||||
|
||||
//const URL_TESTNET = `https://api.s0.b.hmny.io`;
|
||||
const URL_TESTNET = `localhost:9500`; |
||||
const URL_MAINNET = `https://api.s0.t.hmny.io`; |
||||
|
||||
// 1. initialize the Harmony instance
|
||||
|
||||
const harmony = new Harmony( |
||||
// rpc url
|
||||
URL_TESTNET, |
||||
{ |
||||
// chainType set to Harmony
|
||||
chainType: ChainType.Harmony, |
||||
// chainType set to HmyLocal
|
||||
chainId: ChainID.HmyTestnet, |
||||
}, |
||||
); |
||||
|
||||
// 2. get wallet ready
|
||||
// one18n8e7472pg5fqvcfcr5hg0npquha24wsxmjheg
|
||||
//const phrase = 'genius cable radar memory high catch blossom correct middle wish gentle fiscal';
|
||||
|
||||
// one1a2rhuaqjcvfu69met9sque2l3w5v9z6qcdcz65
|
||||
// surge welcome lion goose gate consider taste injury health march debris kick
|
||||
|
||||
// add privateKey to wallet
|
||||
//const sender = harmony.wallet.addByMnemonic(phrase);
|
||||
// add privateKey to wallet
|
||||
const private = 'fd416cb87dcf8ed187e85545d7734a192fc8e976f5b540e9e21e896ec2bc25c3'; |
||||
const sender = harmony.wallet.addByPrivateKey(private); |
||||
|
||||
// 3. get sharding info
|
||||
async function setSharding() { |
||||
// Harmony is a sharded blockchain, each endpoint have sharding structure,
|
||||
// However sharding structure is different between mainnet, testnet and local testnet
|
||||
// We need to get sharding info before doing cross-shard transaction
|
||||
const res = await harmony.blockchain.getShardingStructure(); |
||||
harmony.shardingStructures(res.result); |
||||
} |
||||
|
||||
// 4. get transaction payload ready
|
||||
|
||||
async function transfer(receiver) { |
||||
// run set sharding first, if you want to make a cross-shard transaction
|
||||
await setSharding(); |
||||
|
||||
//1e18
|
||||
const txn = harmony.transactions.newTx({ |
||||
// token send to
|
||||
to: receiver, |
||||
// amount to send
|
||||
value: '100000000000000000', |
||||
// gas limit, you can use string
|
||||
gasLimit: '210000', |
||||
// send token from shardID
|
||||
shardID: 0, |
||||
// send token to toShardID
|
||||
toShardID: 0, |
||||
// gas Price, you can use Unit class, and use Gwei, then remember to use toWei(), which will be transformed to BN
|
||||
gasPrice: new harmony.utils.Unit('100').asGwei().toWei(), |
||||
}); |
||||
|
||||
// sign the transaction use wallet;
|
||||
|
||||
// This will happen at the chrome extension.
|
||||
const signedTxn = await harmony.wallet.signTransaction(txn); |
||||
|
||||
// Now you can use `Transaction.observed()` to listen events
|
||||
|
||||
// Frontend received back the signedTxn and do the followings to Send transaction.
|
||||
signedTxn |
||||
.observed() |
||||
.on('transactionHash', (txnHash) => { |
||||
console.log(''); |
||||
console.log('--- hash ---'); |
||||
console.log(''); |
||||
console.log(txnHash); |
||||
console.log(''); |
||||
}) |
||||
.on('receipt', (receipt) => { |
||||
console.log(''); |
||||
console.log('--- receipt ---'); |
||||
console.log(''); |
||||
console.log(receipt); |
||||
console.log(''); |
||||
}) |
||||
.on('cxReceipt', (receipt) => { |
||||
console.log(''); |
||||
console.log('--- cxReceipt ---'); |
||||
console.log(''); |
||||
console.log(receipt); |
||||
console.log(''); |
||||
}) |
||||
.on('error', (error) => { |
||||
console.log(''); |
||||
console.log('--- error ---'); |
||||
console.log(''); |
||||
console.log(error); |
||||
console.log(''); |
||||
}); |
||||
|
||||
// send the txn, get [Transaction, transactionHash] as result
|
||||
|
||||
const [sentTxn, txnHash] = await signedTxn.sendTransaction(); |
||||
|
||||
// to confirm the result if it is already there
|
||||
|
||||
const confiremdTxn = await sentTxn.confirm(txnHash); |
||||
|
||||
// if the transactino is cross-shard transaction
|
||||
if (!confiremdTxn.isCrossShard()) { |
||||
if (confiremdTxn.isConfirmed()) { |
||||
console.log('--- Result ---'); |
||||
console.log(''); |
||||
console.log('Normal transaction'); |
||||
console.log(`${txnHash} is confirmed`); |
||||
console.log(''); |
||||
process.exit(); |
||||
} |
||||
} |
||||
if (confiremdTxn.isConfirmed() && confiremdTxn.isCxConfirmed()) { |
||||
console.log('--- Result ---'); |
||||
console.log(''); |
||||
console.log('Cross-Shard transaction'); |
||||
console.log(`${txnHash} is confirmed`); |
||||
console.log(''); |
||||
process.exit(); |
||||
} |
||||
} |
||||
|
||||
// sending from one18n8e7472pg5fqvcfcr5hg0npquha24wsxmjheg to one1a2rhuaqjcvfu69met9sque2l3w5v9z6qcdcz65
|
||||
transfer('one1a2rhuaqjcvfu69met9sque2l3w5v9z6qcdcz65'); |
File diff suppressed because it is too large
Load Diff
@ -1,10 +1,12 @@ |
||||
# Packages available are: |
||||
|
||||
1. [@harmony-js/core](https://github.com/harmony-one/sdk/tree/master/packages/harmony-core) |
||||
2. [@harmony-js/account](https://github.com/harmony-one/sdk/tree/master/packages/harmony-account) |
||||
3. [@harmony-js/crypto](https://github.com/harmony-one/sdk/tree/master/packages/harmony-crypto) |
||||
4. [@harmony-js/network](https://github.com/harmony-one/sdk/tree/master/packages/harmony-network) |
||||
5. [@harmony-js/utils](https://github.com/harmony-one/sdk/tree/master/packages/harmony-utils) |
||||
6. [@harmony-js/transaction](https://github.com/harmony-one/sdk/tree/master/packages/harmony-transaction) |
||||
7. [@harmony-js/contract](https://github.com/harmony-one/sdk/tree/master/packages/harmony-contract) |
||||
8. [@harmony-js/staking](https://github.com/harmony-one/sdk/tree/master/packages/harmony-staking) |
||||
1. [@woop-js/core](https://github.com/woop-chain/sdk/tree/master/packages/woop-core) |
||||
2. [@woop-js/account](https://github.com/woop-chain/sdk/tree/master/packages/woop-account) |
||||
3. [@woop-js/crypto](https://github.com/woop-chain/sdk/tree/master/packages/woop-crypto) |
||||
4. [@woop-js/network](https://github.com/woop-chain/sdk/tree/master/packages/woop-network) |
||||
5. [@woop-js/utils](https://github.com/woop-chain/sdk/tree/master/packages/woop-utils) |
||||
6. [@woop-js/transaction](https://github.com/woop-chain/sdk/tree/master/packages/woop-transaction) |
||||
7. [@woop-js/contract](https://github.com/woop-chain/sdk/tree/master/packages/woop-contract) |
||||
8. [@woop-js/staking](https://github.com/woop-chain/sdk/tree/master/packages/woop-staking) |
||||
|
||||
<mark>Package level documentation and examples are inside each package</mark> |
@ -1,274 +0,0 @@ |
||||
/** |
||||
## About This Package |
||||
|
||||
`@harmony-js/account` is dealing with account related features. |
||||
|
||||
Developers can use this package to: |
||||
- Create `Account` instance |
||||
- Create `Wallet` instance |
||||
- Sign `Transaction` |
||||
- Convert address format |
||||
- Manage `privateKey` or `mnemonic phrases` and do the `encrypt` and `decrypt` job |
||||
|
||||
There are 2 main classes in this package, `Account` and `Wallet`. |
||||
|
||||
- The `Account` class is basic instance that contains most features mentioned above. |
||||
- The `Wallet` class is class that stores all `Account` instance, you can do CRUD on it. |
||||
|
||||
|
||||
## Usage of Account |
||||
|
||||
### Dependencies |
||||
- @harmony-js/network |
||||
- @harmony-js/staking |
||||
- @harmony-js/transaction |
||||
- @harmony-js/utils |
||||
|
||||
### Examples |
||||
|
||||
Create a random account |
||||
```javascript
|
||||
// import the Account class
|
||||
import {Account} from '@harmony-js/account' |
||||
|
||||
// Messenger is optional, by default, we have a defaultMessenger
|
||||
// If you like to change, you will import related package here.
|
||||
import { HttpProvider, Messenger } from '@harmony-js/network'; |
||||
import { ChainType, ChainID } from '@harmony-js/utils'; |
||||
|
||||
// create a custom messenger
|
||||
const customMessenger = new Messenger( |
||||
new HttpProvider('http://localhost:9500'), |
||||
ChainType.Harmony, // if you are connected to Harmony's blockchain
|
||||
ChainID.HmyLocal, // check if the chainId is correct
|
||||
) |
||||
|
||||
// to create an Account with random privateKey
|
||||
// and you can setMessenger later
|
||||
const randomAccount = new Account() |
||||
randomAccount.setMessenger(customMessenger) |
||||
|
||||
// or you can set messenger on `new`
|
||||
const randomAccountWithCustomMessenger = new Account(undefined, customMessenger) |
||||
|
||||
// you can display the account
|
||||
console.log({randomAccount,randomAccountWithCustomMessenger}) |
||||
|
||||
// or you can use static method to create an Account
|
||||
const staticCreatedAccount = Account.new() |
||||
// but you have to set messenger manually after
|
||||
staticCreatedAccount.setMessenger(customMessenger) |
||||
|
||||
console.log({staticCreatedAccount}) |
||||
``` |
||||
|
||||
### Import an existing privateKey to create Account |
||||
|
||||
```typescript
|
||||
|
||||
// import the Account class
|
||||
import {Account} from '@harmony-js/account' |
||||
|
||||
// NOTED: Key with or without `0x` are accepted, makes no different
|
||||
// NOTED: DO NOT import `mnemonic phrase` using `Account` class, use `Wallet` instead
|
||||
const myPrivateKey = '0xe19d05c5452598e24caad4a0d85a49146f7be089515c905ae6a19e8a578a6930' |
||||
|
||||
const myAccountWithMyPrivateKey = new Account(myPrivateKey) |
||||
|
||||
// you can also import privateKey use static method
|
||||
const myAccountWithMyPrivateKeyUsingStatic = Account.add(myPrivateKey) |
||||
|
||||
console.log({ myAccountWithMyPrivateKey, myAccountWithMyPrivateKeyUsingStatic }) |
||||
|
||||
``` |
||||
|
||||
### Encrypt/Export keyStore file, Decrypt/Import keyStore file
|
||||
|
||||
```typescript
|
||||
|
||||
// import the Account class
|
||||
import {Account} from '@harmony-js/account' |
||||
|
||||
// suppose we have an account
|
||||
const myPrivateKey = '0xe19d05c5452598e24caad4a0d85a49146f7be089515c905ae6a19e8a578a6930' |
||||
const myAccountWithMyPrivateKey = new Account(myPrivateKey) |
||||
|
||||
// suppose we have a password, and we want to encrypt the account above
|
||||
const myStrongPassword = '123' |
||||
|
||||
async function encryptAndDecrypt(password) { |
||||
// we get the privateKey before encrypted as comparison
|
||||
const unencryptedPrivateKey = myAccountWithMyPrivateKey.privateKey |
||||
|
||||
// export the account to keyStore string, which will make the privateKey encrpyted
|
||||
const keyStoreFile = await myAccountWithMyPrivateKey.toFile(password) |
||||
// exported keyStoreFile
|
||||
console.log({ keyStoreFile }) |
||||
// see if the account is encrypted
|
||||
console.log(`Is this account encrypted? \n ${myAccountWithMyPrivateKey.encrypted}`) |
||||
// keystore file should be equal to encrypted privateKey
|
||||
console.log( |
||||
`Is privateKey equal to keyStore string? \n ${keyStoreFile === |
||||
myAccountWithMyPrivateKey.privateKey}`,
|
||||
) |
||||
} |
||||
|
||||
encryptAndDecrypt(myStrongPassword) |
||||
|
||||
|
||||
// suppose we have keyStorefile, in this example, we just use same password and keystore string encrypted above
|
||||
const someKeyStoreFile = |
||||
'{"version":3,"id":"62326332-3139-4839-b534-656134623066","address":"1fe3da351d9fc0c4f02de5412ad7def8aee956c5","Crypto":{"ciphertext":"b86ab81682c9f5a35738ad9bd38cd9b46c1b852ef33f16dd83068f79e20d5531","cipherparams":{"iv":"44efb5a514f34968e92cafad80566487"},"cipher":"aes-128-ctr","kdf":"scrypt","kdfparams":{"salt":"d70ae1f311601562113f98c8ebe382f52a332dca1588886e5ea91e2f8a647134","n":8192,"r":8,"p":1,"dklen":32},"mac":"7b63e4e31a75a22b7091291bb58302655b738539ef3e30b30a7a7f170f6163ef"}}' |
||||
|
||||
async function importKeyStoreFileAndDecrypt(keyStoreFile, password) { |
||||
// import keyStore string and provide the password, remember to make a new Account first
|
||||
const importedAccount = await Account.new().fromFile(keyStoreFile, password) |
||||
// the account should decypted which `Account.encrypted` is false
|
||||
console.log(`Is this account encrypted? \n ${importedAccount.encrypted}`) |
||||
// see if the privatekey is equal to unencrypted one?
|
||||
console.log( |
||||
`Is the account recovered from keystore? \n ${importedAccount.privateKey === myPrivateKey}`, |
||||
) |
||||
} |
||||
|
||||
importKeyStoreFileAndDecrypt(someKeyStoreFile, myStrongPassword) |
||||
|
||||
|
||||
``` |
||||
|
||||
|
||||
### Address format getter |
||||
|
||||
```typescript
|
||||
|
||||
// import the Account class
|
||||
import {Account} from '@harmony-js/account' |
||||
|
||||
// suppose we have an account
|
||||
const myPrivateKey = '0xe19d05c5452598e24caad4a0d85a49146f7be089515c905ae6a19e8a578a6930' |
||||
const myAccountWithMyPrivateKey = new Account(myPrivateKey) |
||||
|
||||
// Account.address is bytes20/base16 address
|
||||
console.log(myAccountWithMyPrivateKey.address) |
||||
// Account.bech32Address is bech32 format address, in Harmony, it's `one1` prefixed
|
||||
console.log(myAccountWithMyPrivateKey.bech32Address) |
||||
// Account.bech32TestNetAddress is bech32 format address, in Harmony, it's `tone1` prefixed, used in testnet
|
||||
console.log(myAccountWithMyPrivateKey.bech32TestNetAddress) |
||||
// Account.checksumAddress is checksumed address from base16
|
||||
console.log(myAccountWithMyPrivateKey.checksumAddress) |
||||
|
||||
``` |
||||
|
||||
|
||||
### Sign a transaction |
||||
|
||||
```typescript
|
||||
|
||||
// import the Account class
|
||||
import {Account} from '@harmony-js/account' |
||||
|
||||
// import Transaction class from '@harmony-js/transaction'
|
||||
import {Transaction} from '@harmony-js/transaction' |
||||
|
||||
// Messenger is optional, by default, we have a defaultMessenger
|
||||
// If you like to change, you will import related package here.
|
||||
import { HttpProvider, Messenger } from '@harmony-js/network'; |
||||
import { ChainType, ChainID, Unit } from '@harmony-js/utils'; |
||||
|
||||
// create a custom messenger
|
||||
const customMessenger = new Messenger( |
||||
new HttpProvider('http://localhost:9500'), |
||||
ChainType.Harmony, // if you are connected to Harmony's blockchain
|
||||
ChainID.HmyLocal, // check if the chainId is correct
|
||||
) |
||||
// suppose we have an account
|
||||
const myPrivateKey = '0xe19d05c5452598e24caad4a0d85a49146f7be089515c905ae6a19e8a578a6930' |
||||
const myAccountWithMyPrivateKey = new Account(myPrivateKey) |
||||
|
||||
|
||||
const txnObject = { |
||||
// token send to
|
||||
to: 'one166axnkjmghkf3df7xfvd0hn4dft8kemrza4cd2', |
||||
// amount to send
|
||||
value: '1000000000000000000000', |
||||
// gas limit, you can use string or use BN value
|
||||
gasLimit: '210000', |
||||
// send token from shardID
|
||||
shardID: 0, |
||||
// send token to toShardID
|
||||
toShardID: 0, |
||||
// gas Price, you can use Unit class, and use Gwei, then remember to use toWei(), which will be transformed to BN
|
||||
gasPrice: new Unit('100').asGwei().toWei(), |
||||
// if you set nonce manually here, and remember, the `updateNonce` of `Account.signTransaction` should be set to false
|
||||
nonce: 0, |
||||
}; |
||||
|
||||
const txn = new Transaction(txnObject, customMessenger); |
||||
|
||||
async function signTheTxn() { |
||||
// Account.signTransaction(transaction: Transaction, updateNonce?: boolean, encodeMode?: string, blockNumber?: string): Promise<Transaction>
|
||||
// If the 2nd parameter `updateNonce` is set to true, it will query and update account's nonce before it signs
|
||||
const signedTxn = await myAccountWithMyPrivateKey.signTransaction(txn, false, 'rlp', 'latest'); |
||||
|
||||
// see if the transaction is signed
|
||||
console.log(`\n see if transaction is signed: \n ${signedTxn.isSigned()} \n`); |
||||
|
||||
// get the tranaction bytes
|
||||
console.log(`\n the signed bytes is: \n ${signedTxn.getRawTransaction()} \n`); |
||||
|
||||
return signTheTxn; |
||||
} |
||||
|
||||
signTheTxn(); |
||||
``` |
||||
|
||||
|
||||
## Usage of Wallet |
||||
|
||||
### Dependencies |
||||
- @harmony-js/crypto |
||||
- @harmony-js/network |
||||
- @harmony-js/staking |
||||
- @harmony-js/transaction |
||||
- @harmony-js/utils |
||||
|
||||
```typescript
|
||||
// constructor
|
||||
const { Wallet } = require('@harmony-js/account'); |
||||
const wallet = new Wallet(customMessenger); |
||||
|
||||
// get signer
|
||||
const wallet = new Wallet(customMessenger); |
||||
const key_1 = '45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e'; |
||||
console.log(wallet.addByPrivateKey(key_1)); |
||||
console.log(wallet.signer) |
||||
|
||||
// createAccount
|
||||
console.log(wallet.accounts); |
||||
wallet.createAccount(); |
||||
wallet.createAccount(); |
||||
console.log(wallet.accounts); |
||||
|
||||
// encryptAccount
|
||||
const key_1 = '45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e'; |
||||
wallet.addByPrivateKey(key_1); |
||||
wallet.encryptAccount('one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7', '12345').then((value) => { |
||||
console.log(value); |
||||
}) |
||||
|
||||
// decrptAccount
|
||||
const key_1 = '45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e'; |
||||
wallet.addByPrivateKey(key_1); |
||||
wallet.encryptAccount('one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7', '12345').then(() => { |
||||
wallet.decryptAccount('one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7', '12345').then((value) => { |
||||
console.log(value); |
||||
}) |
||||
}); |
||||
``` |
||||
*
|
||||
* @packageDocumentation |
||||
* @module harmony-account |
||||
*/ |
||||
|
||||
/**@ignore */ |
||||
export interface README {} |
@ -1,14 +0,0 @@ |
||||
/** |
||||
* @packageDocumentation |
||||
* @module harmony-account |
||||
* @hidden |
||||
*/ |
||||
|
||||
import { HttpProvider, Messenger } from '@harmony-js/network'; |
||||
import { ChainType, ChainID } from '@harmony-js/utils'; |
||||
|
||||
export const defaultMessenger = new Messenger( |
||||
new HttpProvider('http://localhost:9500'), |
||||
ChainType.Harmony, |
||||
ChainID.HmyLocal, |
||||
); |
@ -1,30 +0,0 @@ |
||||
{ |
||||
"name": "@harmony-js/core", |
||||
"version": "0.1.53", |
||||
"description": "harmony core package", |
||||
"main": "dist/index.js", |
||||
"node": "dist/index.js", |
||||
"browser": "dist/index.js", |
||||
"module": "dist/index.esm.js", |
||||
"jsnext:main": "dist/index.esm.js", |
||||
"typings": "dist/index.d.ts", |
||||
"types": "dist/index.d.ts", |
||||
"scripts": { |
||||
"test": "echo \"Error: no test specified\" && exit 1" |
||||
}, |
||||
"publishConfig": { |
||||
"access": "public" |
||||
}, |
||||
"author": "neeboo@firestack.one", |
||||
"license": "MIT", |
||||
"dependencies": { |
||||
"@harmony-js/account": "0.1.53", |
||||
"@harmony-js/contract": "0.1.53", |
||||
"@harmony-js/crypto": "0.1.48", |
||||
"@harmony-js/network": "0.1.51", |
||||
"@harmony-js/staking": "0.1.51", |
||||
"@harmony-js/transaction": "0.1.51", |
||||
"@harmony-js/utils": "0.1.48" |
||||
}, |
||||
"gitHead": "56606e9365721729a490c27d6a294e0daf90fbdf" |
||||
} |
@ -1,31 +0,0 @@ |
||||
/** |
||||
* @packageDocumentation |
||||
* @module harmony-core |
||||
* @hidden |
||||
*/ |
||||
|
||||
import { HttpProvider, Messenger } from '@harmony-js/network'; |
||||
import { TransactionFactory, Transaction } from '@harmony-js/transaction'; |
||||
import { Wallet, Account } from '@harmony-js/account'; |
||||
import { ChainType, ChainID } from '@harmony-js/utils'; |
||||
import { Blockchain } from './blockchain'; |
||||
|
||||
export interface HarmonyModule { |
||||
HttpProvider: HttpProvider; |
||||
Messenger: Messenger; |
||||
Blockchain: Blockchain; |
||||
TransactionFactory: TransactionFactory; |
||||
Wallet: Wallet; |
||||
Transaction: Transaction; |
||||
Account: Account; |
||||
} |
||||
|
||||
export const enum UrlType { |
||||
http, |
||||
ws, |
||||
} |
||||
|
||||
export interface HarmonySetting<T extends ChainType, I extends ChainID> { |
||||
type: T; |
||||
id: I; |
||||
} |
@ -1,16 +0,0 @@ |
||||
{ |
||||
"extends": "../../tsconfig.base.json", |
||||
"compilerOptions": { |
||||
"rootDir": "src", |
||||
"outDir": "dist" |
||||
}, |
||||
"include": ["src", "../../typings/**/*.d.ts", "../harmony-utils/src/core.ts"], |
||||
"references": [ |
||||
{"path": "../harmony-account"}, |
||||
{"path": "../harmony-crypto"}, |
||||
{"path": "../harmony-utils"}, |
||||
{"path": "../harmony-network"}, |
||||
{"path": "../harmony-transaction"}, |
||||
{"path": "../harmony-contract"} |
||||
] |
||||
} |
@ -1,126 +0,0 @@ |
||||
/** |
||||
* ## About this package |
||||
* |
||||
* `@harmony-js/network` provides functions to handle messenger, providers and subscriptions... |
||||
* |
||||
* ## How to use this package |
||||
* |
||||
* ### 1. Create a Message |
||||
* ```javascript
|
||||
* const { HttpProvider, Messenger } = require('@harmony-js/network'); |
||||
* const { ChainType, ChainID } = require('@harmony-js/utils'); |
||||
* |
||||
* // create a custom messenger
|
||||
* const customMessenger = new Messenger( |
||||
* new HttpProvider('http://localhost:9500'), |
||||
* ChainType.Harmony, // if you are connected to Harmony's blockchain
|
||||
* ChainID.HmyLocal, // check if the chainId is correct
|
||||
* ) |
||||
* ``` |
||||
* |
||||
* @packageDocumentation |
||||
* @module harmony-network |
||||
*/ |
||||
|
||||
/**@ignore */ |
||||
export const enum RPCMethod { |
||||
// 1. hmy_getBlockByHash
|
||||
GetBlockByHash = 'hmy_getBlockByHash', |
||||
// 2. hmy_getBlockByNumber
|
||||
GetBlockByNumber = 'hmy_getBlockByNumber', |
||||
// 3. hmy_getBlockTransactionCountByHash
|
||||
GetBlockTransactionCountByHash = 'hmy_getBlockTransactionCountByHash', |
||||
// 4. hmy_getBlockTransactionCountByNumber
|
||||
GetBlockTransactionCountByNumber = 'hmy_getBlockTransactionCountByNumber', |
||||
// 5. hmy_getCode
|
||||
GetCode = 'hmy_getCode', |
||||
// 6. hmy_getTransactionByBlockHashAndIndex
|
||||
GetTransactionByBlockHashAndIndex = 'hmy_getTransactionByBlockHashAndIndex', |
||||
// 7. hmy_getTransactionByBlockNumberAndIndex
|
||||
GetTransactionByBlockNumberAndIndex = 'hmy_getTransactionByBlockNumberAndIndex', |
||||
// 8. hmy_getTransactionByHash
|
||||
GetTransactionByHash = 'hmy_getTransactionByHash', |
||||
|
||||
GetTransactionReceipt = 'hmy_getTransactionReceipt', |
||||
|
||||
GetCXReceiptByHash = 'hmy_getCXReceiptByHash', |
||||
// 9. hmy_syncing
|
||||
Syncing = 'hmy_syncing', |
||||
// 10. net_peerCount
|
||||
PeerCount = 'net_peerCount', |
||||
|
||||
// 11. hmy_getBalance
|
||||
GetBalance = 'hmy_getBalance', |
||||
// 12. hmy_getStorageAt
|
||||
GetStorageAt = 'hmy_getStorageAt', |
||||
// 13. hmy_getTransactionCount
|
||||
GetTransactionCount = 'hmy_getTransactionCount', |
||||
// 14. hmy_sendTransaction
|
||||
SendTransaction = 'hmy_sendTransaction', |
||||
// 15. hmy_sendRawTransaction
|
||||
SendRawTransaction = 'hmy_sendRawTransaction', |
||||
// 16. hmy_subscribe
|
||||
Subscribe = 'hmy_subscribe', |
||||
// 17. hmy_getlogs
|
||||
GetPastLogs = 'hmy_getLogs', |
||||
// 18. hmy_getWork
|
||||
GetWork = 'hmy_getWork', |
||||
// 19. hmy_submitWork
|
||||
// SubmitWork = 'hmy_submitWork',
|
||||
// 20. hmy_getProof
|
||||
GetProof = 'hmy_getProof', |
||||
// 21, hmy_getFilterChanges
|
||||
GetFilterChanges = 'hmy_getFilterChanges', |
||||
// 22. hmy_newPendingTransactionFilter
|
||||
NewPendingTransactionFilter = 'hmy_newPendingTransactionFilter', |
||||
// 23. hmy_newBlockFilter
|
||||
NewBlockFilter = 'hmy_newBlockFilter', |
||||
// 24. hmy_newFilter
|
||||
NewFilter = 'hmy_newFilter', |
||||
// 25. hmy_call
|
||||
Call = 'hmy_call', |
||||
// 26. hmy_estimateGas
|
||||
EstimateGas = 'hmy_estimateGas', |
||||
// 27. hmy_gasPrice
|
||||
GasPrice = 'hmy_gasPrice', |
||||
// 28. hmy_blockNumber
|
||||
BlockNumber = 'hmy_blockNumber', |
||||
// 29. hmy_unsubscribe
|
||||
UnSubscribe = 'hmy_unsubscribe', |
||||
// 30. net_version
|
||||
NetVersion = 'net_version', |
||||
// 31. hmy_protocolVersion
|
||||
ProtocolVersion = 'hmy_protocolVersion', |
||||
// 32. hmy_getShardingStructure
|
||||
GetShardingStructure = 'hmy_getShardingStructure', |
||||
// 33. hmy_sendRawStakingTransaction
|
||||
SendRawStakingTransaction = 'hmy_sendRawStakingTransaction', |
||||
} |
||||
|
||||
/**@ignore */ |
||||
export const enum RPCErrorCode { |
||||
// Standard JSON-RPC 2.0 errors
|
||||
// RPC_INVALID_REQUEST is internally mapped to HTTP_BAD_REQUEST (400).
|
||||
// It should not be used for application-layer errors.
|
||||
RPC_INVALID_REQUEST = -32600, |
||||
// RPC_METHOD_NOT_FOUND is internally mapped to HTTP_NOT_FOUND (404).
|
||||
// It should not be used for application-layer errors.
|
||||
RPC_METHOD_NOT_FOUND = -32601, |
||||
RPC_INVALID_PARAMS = -32602, |
||||
// RPC_INTERNAL_ERROR should only be used for genuine errors in bitcoind
|
||||
// (for example datadir corruption).
|
||||
RPC_INTERNAL_ERROR = -32603, |
||||
RPC_PARSE_ERROR = -32700, |
||||
|
||||
// General application defined errors
|
||||
RPC_MISC_ERROR = -1, // std::exception thrown in command handling
|
||||
RPC_TYPE_ERROR = -3, // Unexpected type was passed as parameter
|
||||
RPC_INVALID_ADDRESS_OR_KEY = -5, // Invalid address or key
|
||||
RPC_INVALID_PARAMETER = -8, // Invalid, missing or duplicate parameter
|
||||
RPC_DATABASE_ERROR = -20, // Database error
|
||||
RPC_DESERIALIZATION_ERROR = -22, // Error parsing or validating structure in raw format
|
||||
RPC_VERIFY_ERROR = -25, // General error during transaction or block submission
|
||||
RPC_VERIFY_REJECTED = -26, // Transaction or block was rejected by network rules
|
||||
RPC_IN_WARMUP = -28, // Client still warming up
|
||||
RPC_METHOD_DEPRECATED = -32, // RPC method is deprecated
|
||||
} |
@ -1,135 +0,0 @@ |
||||
/** |
||||
* ## About this package |
||||
* |
||||
* `@harmony-js/transaction` provides the functions to build transactions |
||||
* |
||||
* Develop can use this package to: |
||||
* - build a transaction offline! |
||||
* - set params of transaction |
||||
* - |
||||
* |
||||
* ## How to use this package |
||||
* ### Step 1: create a Harmony Instance |
||||
* ```javascript
|
||||
* const { Harmony } = require('@harmony-js/core'); |
||||
* const { ChainID, ChainType } = require('@harmony-js/utils'); |
||||
* const { BN } = require('@harmony-js/crypto'); |
||||
* |
||||
* const hmy = new Harmony( |
||||
* 'http://localhost:9500', |
||||
* { |
||||
* chainType: ChainType.Harmony, |
||||
* chainId: ChainID.HmyLocal, |
||||
* }, |
||||
* ); |
||||
* ``` |
||||
* |
||||
* ### Step 2: build a transaction |
||||
* ```javascript
|
||||
* const txn = hmy.transactions.newTx({ |
||||
* to: 'one166axnkjmghkf3df7xfvd0hn4dft8kemrza4cd2', |
||||
* value: '10000', |
||||
* gasLimit: '210000', |
||||
* shardID: 0, |
||||
* toShardID: 0, |
||||
* gasPrice: new hmy.utils.Unit('100').asGwei().toWei(), |
||||
* }); |
||||
* ``` |
||||
* |
||||
* ## some important information |
||||
* Transaction Parameters |
||||
* ```java
|
||||
* // interface TxParams
|
||||
* id: string; |
||||
* from: string; |
||||
* to: string; |
||||
* nonce: number | string; |
||||
* gasLimit: number | string | BN; |
||||
* gasPrice: number | string | BN; |
||||
* shardID: number | string; |
||||
* toShardID: number | string; |
||||
* data: string; |
||||
* value: number | string | BN; |
||||
* chainId: number; |
||||
* rawTransaction: string; |
||||
* unsignedRawTransaction: string; |
||||
* signature: Signature; |
||||
* receipt?: TransasctionReceipt; |
||||
* ``` |
||||
* |
||||
* Transaction Receipt |
||||
* ```java
|
||||
* // interface TransasctionReceipt
|
||||
* transactionHash: string; |
||||
* transactionIndex: string; |
||||
* blockHash: string; |
||||
* blockNumber: string; // 11
|
||||
* from: string; |
||||
* to: string; |
||||
* gasUsed: string; |
||||
* cumulativeGasUsed: string; // 13244
|
||||
* contractAddress?: string | null; // or null, if none was created
|
||||
* logs: any[]; |
||||
* logsBloom: string; // 256 byte bloom filter
|
||||
* v: string; |
||||
* r: string; |
||||
* s: string; |
||||
* responseType?: string; |
||||
* byzantium?: boolean; |
||||
* status?: string; // post Byzantium will return `0x0` or `0x1`
|
||||
* root?: string; // pre Byzantium will return `root`
|
||||
* ``` |
||||
* |
||||
* @packageDocumentation |
||||
* @module harmony-transaction |
||||
*/ |
||||
|
||||
import { BN, Signature } from '@harmony-js/crypto'; |
||||
|
||||
export interface TxParams { |
||||
id: string; |
||||
from: string; |
||||
to: string; |
||||
nonce: number | string; |
||||
gasLimit: number | string | BN; |
||||
gasPrice: number | string | BN; |
||||
shardID: number | string; |
||||
toShardID: number | string; |
||||
data: string; |
||||
value: number | string | BN; |
||||
chainId: number; |
||||
rawTransaction: string; |
||||
unsignedRawTransaction: string; |
||||
signature: Signature; |
||||
receipt?: TransasctionReceipt; |
||||
} |
||||
|
||||
export const enum TxStatus { |
||||
NONE = 'NONE', |
||||
INTIALIZED = 'INITIALIZED', |
||||
SIGNED = 'SIGNED', |
||||
PENDING = 'PENDING', |
||||
CONFIRMED = 'CONFIRMED', |
||||
REJECTED = 'REJECTED', |
||||
} |
||||
|
||||
export interface TransasctionReceipt { |
||||
transactionHash: string; |
||||
transactionIndex: string; |
||||
blockHash: string; |
||||
blockNumber: string; // 11
|
||||
from: string; |
||||
to: string; |
||||
gasUsed: string; |
||||
cumulativeGasUsed: string; // 13244
|
||||
contractAddress?: string | null; // or null, if none was created
|
||||
logs: any[]; |
||||
logsBloom: string; // 256 byte bloom filter
|
||||
v: string; |
||||
r: string; |
||||
s: string; |
||||
responseType?: string; |
||||
byzantium?: boolean; |
||||
status?: string; // post Byzantium will return `0x0` or `0x1`
|
||||
root?: string; // pre Byzantium will return `root`
|
||||
} |
@ -1,203 +0,0 @@ |
||||
/** |
||||
* ## About this package |
||||
*
|
||||
* `@harmony-js/util` provides utility functions for Harmony dapps and other `harmony-js` packages |
||||
*
|
||||
* Develop can use this package to: |
||||
* - Transform the unit of token (fromWei, toWei...) |
||||
* - Convert variable to different type (hexToBN, numberToHex...) |
||||
* - Check validators information (isAddress, isPublicKey, isBlockNumber...) |
||||
*
|
||||
* ## How to use this package |
||||
*
|
||||
* ### Step 1: create a Harmony Instance |
||||
* ```javascript
|
||||
* const { Harmony } = require('@harmony-js/core'); |
||||
* const { ChainID, ChainType } = require('@harmony-js/utils'); |
||||
* const { BN } = require('@harmony-js/crypto'); |
||||
*
|
||||
* const hmy = new Harmony( |
||||
* 'http://localhost:9500', |
||||
* { |
||||
* chainType: ChainType.Harmony, |
||||
* chainId: ChainID.HmyLocal, |
||||
* }, |
||||
* ); |
||||
* ``` |
||||
*
|
||||
* ### Step 2: Select and call functions |
||||
* Here are some examples: |
||||
*
|
||||
* ```javascript
|
||||
* // numberToString
|
||||
* const num = 123; |
||||
* const str = hmy.utils.numberToString(num) |
||||
* console.log(str); |
||||
*
|
||||
* // add0xToString
|
||||
* const str = '12345'; |
||||
* const expected = hmy.utils.add0xToString(str) |
||||
* console.log(expected); |
||||
*
|
||||
* // fromWei
|
||||
* const Wei = new BN('1000000000000000000'); |
||||
* const expected = hmy.utils.fromWei(Wei, hmy.utils.Units.one); |
||||
* console.log(expected); |
||||
*
|
||||
* // toWei
|
||||
* const one = new BN('1'); |
||||
* const expected = hmy.utils.toWei(one, hmy.utils.Units.one); |
||||
* const num = hmy.utils.numToStr(expected); |
||||
* console.log(num); |
||||
* ``` |
||||
*
|
||||
* ### Step 3: Using unit class to convet the token unit |
||||
* ```javascript
|
||||
* // convert one to Gwei
|
||||
* const one = new hmy.utils.Unit('1').asOne(); |
||||
* const oneToGwei = one.toGwei(); |
||||
* console.log(oneToGwei); |
||||
* ``` |
||||
*
|
||||
* ## Some Important consts and Enums
|
||||
* ### Chain Type |
||||
* ```javascript
|
||||
* Harmony = 'hmy', |
||||
* Ethereum = 'eth', |
||||
* ``` |
||||
*
|
||||
* ### Chain ID |
||||
* ```javascript
|
||||
* Default = 0, |
||||
EthMainnet = 1, |
||||
Morden = 2, |
||||
Ropsten = 3, |
||||
Rinkeby = 4, |
||||
RootstockMainnet = 30, |
||||
RootstockTestnet = 31, |
||||
Kovan = 42, |
||||
EtcMainnet = 61, |
||||
EtcTestnet = 62, |
||||
Geth = 1337, |
||||
Ganache = 0, |
||||
HmyMainnet = 1, |
||||
HmyTestnet = 2, |
||||
HmyLocal = 2, |
||||
HmyPangaea = 3, |
||||
* ``` |
||||
*
|
||||
* ### Default Config |
||||
* ```javascript
|
||||
* export const defaultConfig = { |
||||
* Default: { |
||||
* Chain_ID: ChainID.HmyLocal, |
||||
* Chain_Type: ChainType.Harmony, |
||||
* Chain_URL: 'http://localhost:9500', |
||||
* Network_ID: 'Local', |
||||
* }, |
||||
* DefaultWS: { |
||||
* Chain_ID: ChainID.HmyLocal, |
||||
* Chain_Type: ChainType.Harmony, |
||||
* Chain_URL: 'ws://localhost:9800', |
||||
* Network_ID: 'LocalWS', |
||||
* }, |
||||
* }; |
||||
* ``` |
||||
*
|
||||
* ### Unit Map |
||||
* ``` |
||||
* [Units.wei, '1'], // 1 wei
|
||||
* [Units.Kwei, '1000'], // 1e3 wei
|
||||
* [Units.Mwei, '1000000'], // 1e6 wei
|
||||
* [Units.Gwei, '1000000000'], // 1e9 wei
|
||||
* [Units.szabo, '1000000000000'], // 1e12 wei
|
||||
* [Units.finney, '1000000000000000'], // 1e15 wei
|
||||
* [Units.ether, '1000000000000000000'], // 1e18 wei
|
||||
* [Units.one, '1000000000000000000'], // 1e18 wei
|
||||
* [Units.Kether, '1000000000000000000000'], // 1e21 wei
|
||||
* [Units.Mether, '1000000000000000000000000'], // 1e24 wei
|
||||
* [Units.Gether, '1000000000000000000000000000'], // 1e27 wei
|
||||
* [Units.Tether, '1000000000000000000000000000000'], // 1e30 wei
|
||||
* ``` |
||||
*
|
||||
* @packageDocumentation |
||||
* @module harmony-utils |
||||
*/ |
||||
|
||||
export const enum ChainType { |
||||
Harmony = 'hmy', |
||||
Ethereum = 'eth', |
||||
} |
||||
|
||||
export const enum ChainID { |
||||
Default = 0, |
||||
EthMainnet = 1, |
||||
Morden = 2, |
||||
Ropsten = 3, |
||||
Rinkeby = 4, |
||||
RootstockMainnet = 30, |
||||
RootstockTestnet = 31, |
||||
Kovan = 42, |
||||
EtcMainnet = 61, |
||||
EtcTestnet = 62, |
||||
Geth = 1337, |
||||
Ganache = 0, |
||||
HmyMainnet = 1, |
||||
HmyTestnet = 2, |
||||
HmyLocal = 2, |
||||
HmyPangaea = 3, |
||||
} |
||||
|
||||
/** @hidden */ |
||||
export const defaultConfig = { |
||||
Default: { |
||||
Chain_ID: ChainID.HmyLocal, |
||||
Chain_Type: ChainType.Harmony, |
||||
Chain_URL: 'http://localhost:9500', |
||||
Network_ID: 'Local', |
||||
}, |
||||
DefaultWS: { |
||||
Chain_ID: ChainID.HmyLocal, |
||||
Chain_Type: ChainType.Harmony, |
||||
Chain_URL: 'ws://localhost:9800', |
||||
Network_ID: 'LocalWS', |
||||
}, |
||||
}; |
||||
|
||||
/** @hidden */ |
||||
export abstract class HarmonyCore { |
||||
chainType: ChainType; |
||||
chainId: ChainID; |
||||
constructor(chainType: ChainType, chainId: ChainID = defaultConfig.Default.Chain_ID) { |
||||
this.chainType = chainType; |
||||
this.chainId = chainId; |
||||
} |
||||
get chainPrefix(): string { |
||||
switch (this.chainType) { |
||||
case ChainType.Ethereum: { |
||||
return 'eth'; |
||||
} |
||||
case ChainType.Harmony: { |
||||
return 'hmy'; |
||||
} |
||||
default: { |
||||
return 'hmy'; |
||||
} |
||||
} |
||||
} |
||||
get getChainId(): ChainID { |
||||
return this.chainId; |
||||
} |
||||
public setChainId(chainId: ChainID) { |
||||
this.chainId = chainId; |
||||
} |
||||
public setChainType(chainType: ChainType) { |
||||
this.chainType = chainType; |
||||
} |
||||
} |
||||
|
||||
/** @hidden */ |
||||
export const HDPath = `m/44'/1023'/0'/0/`; |
||||
|
||||
/** @hidden */ |
||||
export const AddressSuffix = '-'; |
@ -0,0 +1,218 @@ |
||||
/** |
||||
# @woop-js/account |
||||
|
||||
This package provides a collection of apis to create accounts and wallets and sign using them. A wallet can hold multiple accounts and account is associated with a unique `one` address. This package also provides facilies to manage account keys. |
||||
|
||||
## Installation |
||||
|
||||
``` |
||||
npm install @woop-js/account |
||||
``` |
||||
|
||||
## Usage |
||||
|
||||
Creating new account and display hex and bech32 (one) addresses
|
||||
```javascript
|
||||
const account = new Account(); // or const account = Account.new()
|
||||
console.log(account.checksumAddress); |
||||
console.log(account.bech32Address); |
||||
``` |
||||
|
||||
Creating new account using private key |
||||
```javascript
|
||||
const account = Account.add('45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e'); |
||||
``` |
||||
|
||||
Creating account using private key and custom messenger |
||||
```javascript
|
||||
* const account = new Account( |
||||
* '45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e', |
||||
* new Messenger( |
||||
* new HttpProvider('https://api.s0.b.hmny.io'), |
||||
* ChainType.Woop, |
||||
* ChainID.WikiTestnet, |
||||
* ), |
||||
* ); |
||||
``` |
||||
|
||||
Creating account and setting custom messenger |
||||
```javascript
|
||||
// uses by default http://localhost:9500 as messenger
|
||||
* const account = new Account(); |
||||
* const customMessenger = new Messenger( |
||||
* new HttpProvider('https://api.s0.b.hmny.io'), |
||||
* ChainType.Woop, |
||||
* ChainID.WikiTestnet, |
||||
* ); |
||||
|
||||
account.setMessenger(customMessenger); |
||||
``` |
||||
|
||||
Storing the account data to keystore file |
||||
```javascript
|
||||
* const passphrase = ''; |
||||
* const account = new Account('45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e'); |
||||
* account.toFile(passphrase).then(keystore => { |
||||
* console.log(keystore); |
||||
* }); |
||||
``` |
||||
|
||||
Fetching account from keystore file |
||||
```javascript
|
||||
* const passphrase = ''; |
||||
* const keystore = '{"version":3,"id":"33363566-3564-4264-a638-363531666335","address":"7c41e0668b551f4f902cfaec05b5bdca68b124ce","crypto":{"ciphertext":"9b09380afb742838b32d9afc0ec1a3df35dbd7a41e3a160d08c07a4d0e79b855","cipherparams":{"iv":"1cd0e0522260eef055b9170f4825f4a0"},"cipher":"aes-128-ctr","kdf":"scrypt","kdfparams":{"salt":"bf35e36c45cccefcef73a4c900f41c682c94c28630d94d2d1f764760d245f30b","n":8192,"r":8,"p":1,"dklen":32},"mac":"25b4442972356bea02af57eba3b87803086d90b5e7657a57b528b89b1aa25f2f"}}'; |
||||
* const account = new Account(); |
||||
* account.fromFile(keystore, passphrase).then(account => { |
||||
* console.log(account.bech32Address); |
||||
* }); |
||||
``` |
||||
|
||||
Get the account balance |
||||
```javascript
|
||||
* const account = new Account( |
||||
* '45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e', |
||||
* new Messenger( |
||||
* new HttpProvider('https://api.s0.b.hmny.io'), |
||||
* ChainType.Woop, |
||||
* ChainID.WikiTestnet, |
||||
* ), |
||||
* ); |
||||
* account.getBalance().then(response => { |
||||
* console.log(response); |
||||
* }); |
||||
``` |
||||
outputs `{ balance: '9126943763247054940484', nonce: 45, shardID: 0 }` |
||||
|
||||
Create a transaction and account, and sign it |
||||
```javascript
|
||||
* const account = new Account( |
||||
* '45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e', |
||||
* new Messenger( |
||||
* new HttpProvider('https://api.s0.b.hmny.io'), |
||||
* ChainType.Woop, |
||||
* ChainID.WikiTestnet, |
||||
* ), |
||||
* ); |
||||
* const { TransactionFactory } = require('@woop-js/transaction'); |
||||
* const { Unit } = require('@woop-js/utils'); |
||||
* const factory = new TransactionFactory(); |
||||
|
||||
* const txn = factory.newTx({ |
||||
* to: 'one166axnkjmghkf3df7xfvd0hn4dft8kemrza4cd2', |
||||
* value: new Unit(1).asOne().toWei(), |
||||
* // gas limit, you can use string
|
||||
* gasLimit: '21000', |
||||
* // send token from shardID
|
||||
* shardID: 0, |
||||
* // send token to toShardID
|
||||
* toShardID: 0, |
||||
* // gas Price, you can use Unit class, and use Gwei, then remember to use toWei(), which will be transformed to BN
|
||||
* gasPrice: new Unit('1').asGwei().toWei(), |
||||
* }); |
||||
|
||||
* account.signTransaction(txn).then((signedTxn) => { |
||||
* console.log(signedTxn); |
||||
* }); |
||||
``` |
||||
|
||||
Similarily staking transactions can be created and signed using account. |
||||
|
||||
A wallet represents user wallet that can hold one or more user accounts. |
||||
|
||||
Creating an empty wallet |
||||
```javascript
|
||||
* const { Wallet } = require('@woop-js/account') |
||||
* const wallet = new Wallet(); |
||||
``` |
||||
|
||||
Setting a messenger to be used to send wallet transactions |
||||
```javascript
|
||||
* wallet.setMessenger( |
||||
* new Messenger( |
||||
* new HttpProvider('https://api.s0.b.hmny.io'), |
||||
* ChainType.Woop, |
||||
* ChainID.WikiTestnet, |
||||
* ), |
||||
* ); |
||||
``` |
||||
|
||||
Create an empty wallet with messenger |
||||
```javascript
|
||||
* const wallet = new Wallet( |
||||
* new Messenger( |
||||
* new HttpProvider('https://api.s0.b.hmny.io'), |
||||
* ChainType.Woop, |
||||
* ChainID.WikiTestnet, |
||||
* ), |
||||
* ); |
||||
``` |
||||
|
||||
An account could be added to a wallet using different ways. Adding account using mnemonics |
||||
```javascript
|
||||
const mnemonics = 'horse distance dry brother pretty manual chicken mushroom town swim prize clutch'; |
||||
const account = wallet.addByMnemonic(mnemonics); |
||||
``` |
||||
|
||||
Adding account using private key |
||||
```javascript
|
||||
const account = wallet.addByPrivateKey('0x676cd9773dd23a4c1d7f22767c61c7b6723cc6be37b078545f6e0e91433a23dd') |
||||
``` |
||||
|
||||
Adding account using keystore file |
||||
```javascript
|
||||
* const keystore = '{"version":3,"id":"33363566-3564-4264-a638-363531666335","address":"7c41e0668b551f4f902cfaec05b5bdca68b124ce","crypto":{"ciphertext":"9b09380afb742838b32d9afc0ec1a3df35dbd7a41e3a160d08c07a4d0e79b855","cipherparams":{"iv":"1cd0e0522260eef055b9170f4825f4a0"},"cipher":"aes-128-ctr","kdf":"scrypt","kdfparams":{"salt":"bf35e36c45cccefcef73a4c900f41c682c94c28630d94d2d1f764760d245f30b","n":8192,"r":8,"p":1,"dklen":32},"mac":"25b4442972356bea02af57eba3b87803086d90b5e7657a57b528b89b1aa25f2f"}}'; |
||||
* const passphrase = ''; |
||||
* wallet.addByKeyStore(keystore, passphrase).then(account => { |
||||
* console.log(account.bech32Address); |
||||
* }); |
||||
``` |
||||
|
||||
Creating a new account using passphrase |
||||
```javascript
|
||||
* const passphrase = 'woop-chain'; |
||||
* wallet.createAccount(passphrase).then(account => { |
||||
* console.log(account.bech32Address); |
||||
* }); |
||||
``` |
||||
|
||||
Get all accounts in the wallet |
||||
```javascript
|
||||
* wallet.accounts.forEach(addr => { |
||||
* const account = wallet.getAccount(addr); |
||||
* console.log(account.bech32Address); |
||||
* }); |
||||
``` |
||||
|
||||
Set wallet signer when multiple accounts exists in the wallet |
||||
```javascript
|
||||
wallet.setSigner(signerAddr); |
||||
``` |
||||
|
||||
Sign transaction using wallet, will sign the transaction using the wallet signer |
||||
```javascript
|
||||
* const txn = factory.newTx({ |
||||
* to: 'one166axnkjmghkf3df7xfvd0hn4dft8kemrza4cd2', |
||||
* value: new Unit(1).asOne().toWei(), |
||||
* // gas limit, you can use string
|
||||
* gasLimit: '21000', |
||||
* // send token from shardID
|
||||
* shardID: 0, |
||||
* // send token to toShardID
|
||||
* toShardID: 0, |
||||
* // gas Price, you can use Unit class, and use Gwei, then remember to use toWei(), which will be transformed to BN
|
||||
* gasPrice: new Unit('1').asGwei().toWei(), |
||||
* }); |
||||
|
||||
* wallet.signTransaction(txn).then((signedTxn) => { |
||||
* console.log(signedTxn); |
||||
* }); |
||||
``` |
||||
|
||||
Similarily staking transactions can be signed using `signStaking` api. |
||||
*
|
||||
* @packageDocumentation |
||||
* @module woop-account |
||||
*/ |
||||
|
||||
/**@ignore */ |
||||
export interface README {} |
@ -0,0 +1,29 @@ |
||||
{ |
||||
"name": "@woop-js/account", |
||||
"version": "0.1.58", |
||||
"description": "account and wallet for woop", |
||||
"main": "dist/index.js", |
||||
"node": "dist/index.js", |
||||
"browser": "dist/index.js", |
||||
"module": "dist/index.esm.js", |
||||
"jsnext:main": "dist/index.esm.js", |
||||
"typings": "dist/index.d.ts", |
||||
"types": "dist/index.d.ts", |
||||
"scripts": { |
||||
"test": "echo \"Error: no test specified\" && exit 1" |
||||
}, |
||||
"publishConfig": { |
||||
"access": "public" |
||||
}, |
||||
"author": "neeboo@firestack.one", |
||||
"license": "MIT", |
||||
"dependencies": { |
||||
"@woop-js/core": "0.1.58", |
||||
"@woop-js/crypto": "0.1.58", |
||||
"@woop-js/network": "0.1.58", |
||||
"@woop-js/staking": "0.1.58", |
||||
"@woop-js/transaction": "0.1.58", |
||||
"@woop-js/utils": "0.1.58" |
||||
}, |
||||
"gitHead": "56606e9365721729a490c27d6a294e0daf90fbdf" |
||||
} |
@ -1,6 +1,6 @@ |
||||
/** |
||||
* @packageDocumentation |
||||
* @module harmony-account |
||||
* @module woop-account |
||||
* @ignore |
||||
*/ |
||||
|
@ -1,6 +1,6 @@ |
||||
/** |
||||
* @packageDocumentation |
||||
* @module harmony-account |
||||
* @module woop-account |
||||
* @hidden |
||||
*/ |
||||
|
@ -0,0 +1,14 @@ |
||||
/** |
||||
* @packageDocumentation |
||||
* @module woop-account |
||||
* @hidden |
||||
*/ |
||||
|
||||
import { HttpProvider, Messenger } from '@woop-js/network'; |
||||
import { ChainType, ChainID } from '@woop-js/utils'; |
||||
|
||||
export const defaultMessenger = new Messenger( |
||||
new HttpProvider('http://localhost:9500'), |
||||
ChainType.Woop, |
||||
ChainID.WikiLocal, |
||||
); |
@ -1,18 +1,29 @@ |
||||
/** |
||||
* @packageDocumentation |
||||
* @module harmony-account |
||||
* @module woop-account |
||||
* @ignore |
||||
*/ |
||||
|
||||
import fetch from 'jest-fetch-mock'; |
||||
import { Account } from '../src/account'; |
||||
import { HttpProvider, Messenger } from '@harmony-js/network'; |
||||
import { ChainType, ChainID } from '@harmony-js/utils'; |
||||
import { HttpProvider, Messenger } from '@woop-js/network'; |
||||
import { ChainType, ChainID } from '@woop-js/utils'; |
||||
|
||||
const provider = new HttpProvider('http://localhost:9500'); |
||||
const messenger = new Messenger(provider, ChainType.Harmony, ChainID.HmyLocal); |
||||
const messenger = new Messenger(provider, ChainType.Woop, ChainID.WikiLocal); |
||||
|
||||
describe('test account', () => { |
||||
it('test Account.getBalance returns object that implements Balance interface', () => { |
||||
fetch.mockResponses( |
||||
[ |
||||
JSON.stringify({"jsonrpc": "2.0", "id": 1, "result": "0x166c690f33421e"}), |
||||
{ status: 200 } |
||||
], |
||||
[ |
||||
JSON.stringify({"jsonrpc": "2.0", "id": 1, "result": "0x106"}), |
||||
{ status: 200 } |
||||
] |
||||
); |
||||
const acc = Account.new(); |
||||
acc.setMessenger(messenger); |
||||
acc.getBalance().then((res) => { |
@ -1,12 +1,12 @@ |
||||
/** |
||||
* @packageDocumentation |
||||
* @module harmony-contract |
||||
* @module woop-contract |
||||
* @hidden |
||||
*/ |
||||
|
||||
import { AbiCoder as ABICoder, ParamType, toUtf8Bytes } from './abiCoder'; |
||||
import { isObject, isArray } from '@harmony-js/utils'; |
||||
import { keccak256, Arrayish } from '@harmony-js/crypto'; |
||||
import { isObject, isArray } from '@woop-js/utils'; |
||||
import { keccak256, Arrayish } from '@woop-js/crypto'; |
||||
import { jsonInterfaceMethodToString, bnToString } from './utils'; |
||||
|
||||
export class AbiCoderClass { |
@ -1,6 +1,6 @@ |
||||
/** |
||||
* @packageDocumentation |
||||
* @module harmony-contract |
||||
* @module woop-contract |
||||
* @hidden |
||||
*/ |
||||
|
@ -1,11 +1,11 @@ |
||||
/** |
||||
* @packageDocumentation |
||||
* @module harmony-contract |
||||
* @module woop-contract |
||||
* @hidden |
||||
*/ |
||||
|
||||
import { isObject, isArray } from '@harmony-js/utils'; |
||||
import { BN } from '@harmony-js/crypto'; |
||||
import { isObject, isArray } from '@woop-js/utils'; |
||||
import { BN } from '@woop-js/crypto'; |
||||
|
||||
export const jsonInterfaceMethodToString = (json: any): string => { |
||||
if (isObject(json) && json.name && json.name.includes('(')) { |
@ -1,9 +1,9 @@ |
||||
/** |
||||
* @packageDocumentation |
||||
* @module harmony-contract |
||||
* @module woop-contract |
||||
*/ |
||||
|
||||
import { Wallet } from '@harmony-js/account'; |
||||
import { Wallet } from '@woop-js/account'; |
||||
import { Contract } from './contract'; |
||||
import { ContractOptions } from './utils/options'; |
||||
|
@ -1,9 +1,9 @@ |
||||
/** |
||||
* @packageDocumentation |
||||
* @module harmony-contract |
||||
* @module woop-contract |
||||
*/ |
||||
|
||||
import { LogSub } from '@harmony-js/network'; |
||||
import { LogSub } from '@woop-js/network'; |
||||
import { AbiItemModel } from '../models/types'; |
||||
import { Contract } from '../contract'; |
||||
import { decode as eventLogDecoder } from '../utils/decoder'; |
@ -1,10 +1,10 @@ |
||||
/** |
||||
* @packageDocumentation |
||||
* @module harmony-contract |
||||
* @module woop-contract |
||||
* @hidden |
||||
*/ |
||||
|
||||
import { isArray } from '@harmony-js/utils'; |
||||
import { isArray } from '@woop-js/utils'; |
||||
import { AbiCoderClass } from '../abi/api'; |
||||
import { AbiModel, AbiItemModel } from '../models/types'; |
||||
import { Contract } from '../contract'; |
@ -1,6 +1,6 @@ |
||||
/** |
||||
* @packageDocumentation |
||||
* @module harmony-contract |
||||
* @module woop-contract |
||||
* @hidden |
||||
*/ |
||||
|
@ -1,10 +1,10 @@ |
||||
/** |
||||
* @packageDocumentation |
||||
* @module harmony-contract |
||||
* @module woop-contract |
||||
* @hidden |
||||
*/ |
||||
|
||||
import { isArray } from '@harmony-js/utils'; |
||||
import { isArray } from '@woop-js/utils'; |
||||
import { AbiItemModel, AbiOutput, AbiInput } from './types'; |
||||
|
||||
export class AbiItem { |
@ -1,6 +1,6 @@ |
||||
/** |
||||
* @packageDocumentation |
||||
* @module harmony-contract |
||||
* @module woop-contract |
||||
* @hidden |
||||
*/ |
||||
|
@ -1,6 +1,6 @@ |
||||
/** |
||||
* @packageDocumentation |
||||
* @module harmony-contract |
||||
* @module woop-contract |
||||
* @hidden |
||||
*/ |
||||
|
@ -1,6 +1,6 @@ |
||||
/** |
||||
* @packageDocumentation |
||||
* @module harmony-contract |
||||
* @module woop-contract |
||||
* @hidden |
||||
*/ |
||||
|
@ -1,6 +1,6 @@ |
||||
/** |
||||
* @packageDocumentation |
||||
* @module harmony-contract |
||||
* @module woop-contract |
||||
* @hidden |
||||
*/ |
||||
|
@ -1,11 +1,11 @@ |
||||
/** |
||||
* @packageDocumentation |
||||
* @module harmony-core |
||||
* @module woop-core |
||||
* @hidden |
||||
*/ |
||||
|
||||
export * from './harmony'; |
||||
export * from './woop'; |
||||
export * from './blockchain'; |
||||
export * from './truffleProvider'; |
||||
export * from './harmonyExtension'; |
||||
export * from './woopExtension'; |
||||
export * from './types'; |
@ -0,0 +1,31 @@ |
||||
/** |
||||
* @packageDocumentation |
||||
* @module woop-core |
||||
* @hidden |
||||
*/ |
||||
|
||||
import { HttpProvider, Messenger } from '@woop-js/network'; |
||||
import { TransactionFactory, Transaction } from '@woop-js/transaction'; |
||||
import { Wallet, Account } from '@woop-js/account'; |
||||
import { ChainType, ChainID } from '@woop-js/utils'; |
||||
import { Blockchain } from './blockchain'; |
||||
|
||||
export interface WoopModule { |
||||
HttpProvider: HttpProvider; |
||||
Messenger: Messenger; |
||||
Blockchain: Blockchain; |
||||
TransactionFactory: TransactionFactory; |
||||
Wallet: Wallet; |
||||
Transaction: Transaction; |
||||
Account: Account; |
||||
} |
||||
|
||||
export enum UrlType { |
||||
http, |
||||
ws, |
||||
} |
||||
|
||||
export interface WoopSetting<T extends ChainType, I extends ChainID> { |
||||
type: T; |
||||
id: I; |
||||
} |
@ -0,0 +1,16 @@ |
||||
{ |
||||
"extends": "../../tsconfig.base.json", |
||||
"compilerOptions": { |
||||
"rootDir": "src", |
||||
"outDir": "dist" |
||||
}, |
||||
"include": ["src", "../../typings/**/*.d.ts", "../woop-utils/src/core.ts"], |
||||
"references": [ |
||||
{"path": "../woop-account"}, |
||||
{"path": "../woop-crypto"}, |
||||
{"path": "../woop-utils"}, |
||||
{"path": "../woop-network"}, |
||||
{"path": "../woop-transaction"}, |
||||
{"path": "../woop-contract"} |
||||
] |
||||
} |
@ -0,0 +1,782 @@ |
||||
{ |
||||
"name": "@woop-js/crypto", |
||||
"version": "0.1.58", |
||||
"lockfileVersion": 2, |
||||
"requires": true, |
||||
"packages": { |
||||
"": { |
||||
"name": "@woop-js/crypto", |
||||
"version": "0.1.56", |
||||
"license": "MIT", |
||||
"dependencies": { |
||||
"@woop-js/utils": "0.1.56", |
||||
"aes-js": "^3.1.2", |
||||
"bip39": "^2.5.0", |
||||
"bn.js": "^4.11.8", |
||||
"elliptic": "^6.4.1", |
||||
"hdkey": "^1.1.1", |
||||
"hmac-drbg": "^1.0.1", |
||||
"js-sha3": "^0.8.0", |
||||
"pbkdf2": "^3.0.17", |
||||
"scrypt.js": "^0.3.0", |
||||
"uuid": "^3.3.2" |
||||
} |
||||
}, |
||||
"node_modules/@woop-js/utils": { |
||||
"version": "0.1.56", |
||||
"resolved": "https://registry.npmjs.org/@woop-js/utils/-/utils-0.1.56.tgz", |
||||
"integrity": "sha512-XoYYIMoK/mSxPkxFd25dY/wScIWWevoTrHoFdlFd8N7GWlilfdgQEF5vO+4BA6hyDJ4ryfdLnGc6W6Hz+5qs2A==", |
||||
"dependencies": { |
||||
"@types/bn.js": "^4.11.3", |
||||
"bn.js": "^4.11.8" |
||||
} |
||||
}, |
||||
"node_modules/@types/bn.js": { |
||||
"version": "4.11.6", |
||||
"resolved": "https://registry.npmjs.org/@types/bn.js/-/bn.js-4.11.6.tgz", |
||||
"integrity": "sha512-pqr857jrp2kPuO9uRjZ3PwnJTjoQy+fcdxvBTvHm6dkmEL9q+hDD/2j/0ELOBPtPnS8LjCX0gI9nbl8lVkadpg==", |
||||
"dependencies": { |
||||
"@types/node": "*" |
||||
} |
||||
}, |
||||
"node_modules/@types/node": { |
||||
"version": "14.11.2", |
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.11.2.tgz", |
||||
"integrity": "sha512-jiE3QIxJ8JLNcb1Ps6rDbysDhN4xa8DJJvuC9prr6w+1tIh+QAbYyNF3tyiZNLDBIuBCf4KEcV2UvQm/V60xfA==" |
||||
}, |
||||
"node_modules/aes-js": { |
||||
"version": "3.1.2", |
||||
"resolved": "https://registry.npmjs.org/aes-js/-/aes-js-3.1.2.tgz", |
||||
"integrity": "sha512-e5pEa2kBnBOgR4Y/p20pskXI74UEz7de8ZGVo58asOtvSVG5YAbJeELPZxOmt+Bnz3rX753YKhfIn4X4l1PPRQ==" |
||||
}, |
||||
"node_modules/base-x": { |
||||
"version": "3.0.8", |
||||
"resolved": "https://registry.npmjs.org/base-x/-/base-x-3.0.8.tgz", |
||||
"integrity": "sha512-Rl/1AWP4J/zRrk54hhlxH4drNxPJXYUaKffODVI53/dAsV4t9fBxyxYKAVPU1XBHxYwOWP9h9H0hM2MVw4YfJA==", |
||||
"dependencies": { |
||||
"safe-buffer": "^5.0.1" |
||||
} |
||||
}, |
||||
"node_modules/bindings": { |
||||
"version": "1.5.0", |
||||
"resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", |
||||
"integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", |
||||
"dependencies": { |
||||
"file-uri-to-path": "1.0.0" |
||||
} |
||||
}, |
||||
"node_modules/bip39": { |
||||
"version": "2.6.0", |
||||
"resolved": "https://registry.npmjs.org/bip39/-/bip39-2.6.0.tgz", |
||||
"integrity": "sha512-RrnQRG2EgEoqO24ea+Q/fftuPUZLmrEM3qNhhGsA3PbaXaCW791LTzPuVyx/VprXQcTbPJ3K3UeTna8ZnVl2sg==", |
||||
"dependencies": { |
||||
"create-hash": "^1.1.0", |
||||
"pbkdf2": "^3.0.9", |
||||
"randombytes": "^2.0.1", |
||||
"safe-buffer": "^5.0.1", |
||||
"unorm": "^1.3.3" |
||||
} |
||||
}, |
||||
"node_modules/bip66": { |
||||
"version": "1.1.5", |
||||
"resolved": "https://registry.npmjs.org/bip66/-/bip66-1.1.5.tgz", |
||||
"integrity": "sha1-AfqHSHhcpwlV1QESF9GzE5lpyiI=", |
||||
"dependencies": { |
||||
"safe-buffer": "^5.0.1" |
||||
} |
||||
}, |
||||
"node_modules/bn.js": { |
||||
"version": "4.11.8", |
||||
"resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.8.tgz", |
||||
"integrity": "sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA==" |
||||
}, |
||||
"node_modules/brorand": { |
||||
"version": "1.1.0", |
||||
"resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz", |
||||
"integrity": "sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8=" |
||||
}, |
||||
"node_modules/browserify-aes": { |
||||
"version": "1.2.0", |
||||
"resolved": "https://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz", |
||||
"integrity": "sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA==", |
||||
"dependencies": { |
||||
"buffer-xor": "^1.0.3", |
||||
"cipher-base": "^1.0.0", |
||||
"create-hash": "^1.1.0", |
||||
"evp_bytestokey": "^1.0.3", |
||||
"inherits": "^2.0.1", |
||||
"safe-buffer": "^5.0.1" |
||||
} |
||||
}, |
||||
"node_modules/bs58": { |
||||
"version": "4.0.1", |
||||
"resolved": "https://registry.npmjs.org/bs58/-/bs58-4.0.1.tgz", |
||||
"integrity": "sha1-vhYedsNU9veIrkBx9j806MTwpCo=", |
||||
"dependencies": { |
||||
"base-x": "^3.0.2" |
||||
} |
||||
}, |
||||
"node_modules/bs58check": { |
||||
"version": "2.1.2", |
||||
"resolved": "https://registry.npmjs.org/bs58check/-/bs58check-2.1.2.tgz", |
||||
"integrity": "sha512-0TS1jicxdU09dwJMNZtVAfzPi6Q6QeN0pM1Fkzrjn+XYHvzMKPU3pHVpva+769iNVSfIYWf7LJ6WR+BuuMf8cA==", |
||||
"dependencies": { |
||||
"bs58": "^4.0.0", |
||||
"create-hash": "^1.1.0", |
||||
"safe-buffer": "^5.1.2" |
||||
} |
||||
}, |
||||
"node_modules/buffer-xor": { |
||||
"version": "1.0.3", |
||||
"resolved": "https://registry.npmjs.org/buffer-xor/-/buffer-xor-1.0.3.tgz", |
||||
"integrity": "sha1-JuYe0UIvtw3ULm42cp7VHYVf6Nk=" |
||||
}, |
||||
"node_modules/cipher-base": { |
||||
"version": "1.0.4", |
||||
"resolved": "https://registry.npmjs.org/cipher-base/-/cipher-base-1.0.4.tgz", |
||||
"integrity": "sha512-Kkht5ye6ZGmwv40uUDZztayT2ThLQGfnj/T71N/XzeZeo3nf8foyW7zGTsPYkEya3m5f3cAypH+qe7YOrM1U2Q==", |
||||
"dependencies": { |
||||
"inherits": "^2.0.1", |
||||
"safe-buffer": "^5.0.1" |
||||
} |
||||
}, |
||||
"node_modules/create-hash": { |
||||
"version": "1.2.0", |
||||
"resolved": "https://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz", |
||||
"integrity": "sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg==", |
||||
"dependencies": { |
||||
"cipher-base": "^1.0.1", |
||||
"inherits": "^2.0.1", |
||||
"md5.js": "^1.3.4", |
||||
"ripemd160": "^2.0.1", |
||||
"sha.js": "^2.4.0" |
||||
} |
||||
}, |
||||
"node_modules/create-hmac": { |
||||
"version": "1.1.7", |
||||
"resolved": "https://registry.npmjs.org/create-hmac/-/create-hmac-1.1.7.tgz", |
||||
"integrity": "sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg==", |
||||
"dependencies": { |
||||
"cipher-base": "^1.0.3", |
||||
"create-hash": "^1.1.0", |
||||
"inherits": "^2.0.1", |
||||
"ripemd160": "^2.0.0", |
||||
"safe-buffer": "^5.0.1", |
||||
"sha.js": "^2.4.8" |
||||
} |
||||
}, |
||||
"node_modules/drbg.js": { |
||||
"version": "1.0.1", |
||||
"resolved": "https://registry.npmjs.org/drbg.js/-/drbg.js-1.0.1.tgz", |
||||
"integrity": "sha1-Pja2xCs3BDgjzbwzLVjzHiRFSAs=", |
||||
"dependencies": { |
||||
"browserify-aes": "^1.0.6", |
||||
"create-hash": "^1.1.2", |
||||
"create-hmac": "^1.1.4" |
||||
}, |
||||
"engines": { |
||||
"node": ">=0.10" |
||||
} |
||||
}, |
||||
"node_modules/elliptic": { |
||||
"version": "6.5.3", |
||||
"resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.3.tgz", |
||||
"integrity": "sha512-IMqzv5wNQf+E6aHeIqATs0tOLeOTwj1QKbRcS3jBbYkl5oLAserA8yJTT7/VyHUYG91PRmPyeQDObKLPpeS4dw==", |
||||
"dependencies": { |
||||
"bn.js": "^4.4.0", |
||||
"brorand": "^1.0.1", |
||||
"hash.js": "^1.0.0", |
||||
"hmac-drbg": "^1.0.0", |
||||
"inherits": "^2.0.1", |
||||
"minimalistic-assert": "^1.0.0", |
||||
"minimalistic-crypto-utils": "^1.0.0" |
||||
} |
||||
}, |
||||
"node_modules/evp_bytestokey": { |
||||
"version": "1.0.3", |
||||
"resolved": "https://registry.npmjs.org/evp_bytestokey/-/evp_bytestokey-1.0.3.tgz", |
||||
"integrity": "sha512-/f2Go4TognH/KvCISP7OUsHn85hT9nUkxxA9BEWxFn+Oj9o8ZNLm/40hdlgSLyuOimsrTKLUMEorQexp/aPQeA==", |
||||
"dependencies": { |
||||
"md5.js": "^1.3.4", |
||||
"safe-buffer": "^5.1.1" |
||||
} |
||||
}, |
||||
"node_modules/file-uri-to-path": { |
||||
"version": "1.0.0", |
||||
"resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", |
||||
"integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==" |
||||
}, |
||||
"node_modules/hash-base": { |
||||
"version": "3.1.0", |
||||
"resolved": "https://registry.npmjs.org/hash-base/-/hash-base-3.1.0.tgz", |
||||
"integrity": "sha512-1nmYp/rhMDiE7AYkDw+lLwlAzz0AntGIe51F3RfFfEqyQ3feY2eI/NcwC6umIQVOASPMsWJLJScWKSSvzL9IVA==", |
||||
"dependencies": { |
||||
"inherits": "^2.0.4", |
||||
"readable-stream": "^3.6.0", |
||||
"safe-buffer": "^5.2.0" |
||||
}, |
||||
"engines": { |
||||
"node": ">=4" |
||||
} |
||||
}, |
||||
"node_modules/hash.js": { |
||||
"version": "1.1.7", |
||||
"resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.7.tgz", |
||||
"integrity": "sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA==", |
||||
"dependencies": { |
||||
"inherits": "^2.0.3", |
||||
"minimalistic-assert": "^1.0.1" |
||||
} |
||||
}, |
||||
"node_modules/hdkey": { |
||||
"version": "1.1.2", |
||||
"resolved": "https://registry.npmjs.org/hdkey/-/hdkey-1.1.2.tgz", |
||||
"integrity": "sha512-PTQ4VKu0oRnCrYfLp04iQZ7T2Cxz0UsEXYauk2j8eh6PJXCpbXuCFhOmtIFtbET0i3PMWmHN9J11gU8LEgUljQ==", |
||||
"dependencies": { |
||||
"bs58check": "^2.1.2", |
||||
"safe-buffer": "^5.1.1", |
||||
"secp256k1": "^3.0.1" |
||||
} |
||||
}, |
||||
"node_modules/hmac-drbg": { |
||||
"version": "1.0.1", |
||||
"resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz", |
||||
"integrity": "sha1-0nRXAQJabHdabFRXk+1QL8DGSaE=", |
||||
"dependencies": { |
||||
"hash.js": "^1.0.3", |
||||
"minimalistic-assert": "^1.0.0", |
||||
"minimalistic-crypto-utils": "^1.0.1" |
||||
} |
||||
}, |
||||
"node_modules/inherits": { |
||||
"version": "2.0.4", |
||||
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", |
||||
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" |
||||
}, |
||||
"node_modules/js-sha3": { |
||||
"version": "0.8.0", |
||||
"resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.8.0.tgz", |
||||
"integrity": "sha512-gF1cRrHhIzNfToc802P800N8PpXS+evLLXfsVpowqmAFR9uwbi89WvXg2QspOmXL8QL86J4T1EpFu+yUkwJY3Q==" |
||||
}, |
||||
"node_modules/md5.js": { |
||||
"version": "1.3.5", |
||||
"resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.5.tgz", |
||||
"integrity": "sha512-xitP+WxNPcTTOgnTJcrhM0xvdPepipPSf3I8EIpGKeFLjt3PlJLIDG3u8EX53ZIubkb+5U2+3rELYpEhHhzdkg==", |
||||
"dependencies": { |
||||
"hash-base": "^3.0.0", |
||||
"inherits": "^2.0.1", |
||||
"safe-buffer": "^5.1.2" |
||||
} |
||||
}, |
||||
"node_modules/minimalistic-assert": { |
||||
"version": "1.0.1", |
||||
"resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz", |
||||
"integrity": "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==" |
||||
}, |
||||
"node_modules/minimalistic-crypto-utils": { |
||||
"version": "1.0.1", |
||||
"resolved": "https://registry.npmjs.org/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz", |
||||
"integrity": "sha1-9sAMHAsIIkblxNmd+4x8CDsrWCo=" |
||||
}, |
||||
"node_modules/nan": { |
||||
"version": "2.14.1", |
||||
"resolved": "https://registry.npmjs.org/nan/-/nan-2.14.1.tgz", |
||||
"integrity": "sha512-isWHgVjnFjh2x2yuJ/tj3JbwoHu3UC2dX5G/88Cm24yB6YopVgxvBObDY7n5xW6ExmFhJpSEQqFPvq9zaXc8Jw==" |
||||
}, |
||||
"node_modules/pbkdf2": { |
||||
"version": "3.0.17", |
||||
"resolved": "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.0.17.tgz", |
||||
"integrity": "sha512-U/il5MsrZp7mGg3mSQfn742na2T+1/vHDCG5/iTI3X9MKUuYUZVLQhyRsg06mCgDBTd57TxzgZt7P+fYfjRLtA==", |
||||
"dependencies": { |
||||
"create-hash": "^1.1.2", |
||||
"create-hmac": "^1.1.4", |
||||
"ripemd160": "^2.0.1", |
||||
"safe-buffer": "^5.0.1", |
||||
"sha.js": "^2.4.8" |
||||
}, |
||||
"engines": { |
||||
"node": ">=0.12" |
||||
} |
||||
}, |
||||
"node_modules/randombytes": { |
||||
"version": "2.1.0", |
||||
"resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", |
||||
"integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", |
||||
"dependencies": { |
||||
"safe-buffer": "^5.1.0" |
||||
} |
||||
}, |
||||
"node_modules/readable-stream": { |
||||
"version": "3.6.0", |
||||
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", |
||||
"integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", |
||||
"dependencies": { |
||||
"inherits": "^2.0.3", |
||||
"string_decoder": "^1.1.1", |
||||
"util-deprecate": "^1.0.1" |
||||
}, |
||||
"engines": { |
||||
"node": ">= 6" |
||||
} |
||||
}, |
||||
"node_modules/ripemd160": { |
||||
"version": "2.0.2", |
||||
"resolved": "https://registry.npmjs.org/ripemd160/-/ripemd160-2.0.2.tgz", |
||||
"integrity": "sha512-ii4iagi25WusVoiC4B4lq7pbXfAp3D9v5CwfkY33vffw2+pkDjY1D8GaN7spsxvCSx8dkPqOZCEZyfxcmJG2IA==", |
||||
"dependencies": { |
||||
"hash-base": "^3.0.0", |
||||
"inherits": "^2.0.1" |
||||
} |
||||
}, |
||||
"node_modules/safe-buffer": { |
||||
"version": "5.2.0", |
||||
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.0.tgz", |
||||
"integrity": "sha512-fZEwUGbVl7kouZs1jCdMLdt95hdIv0ZeHg6L7qPeciMZhZ+/gdesW4wgTARkrFWEpspjEATAzUGPG8N2jJiwbg==" |
||||
}, |
||||
"node_modules/scrypt.js": { |
||||
"version": "0.3.0", |
||||
"resolved": "https://registry.npmjs.org/scrypt.js/-/scrypt.js-0.3.0.tgz", |
||||
"integrity": "sha512-42LTc1nyFsyv/o0gcHtDztrn+aqpkaCNt5Qh7ATBZfhEZU7IC/0oT/qbBH+uRNoAPvs2fwiOId68FDEoSRA8/A==", |
||||
"dependencies": { |
||||
"scryptsy": "^1.2.1" |
||||
}, |
||||
"optionalDependencies": { |
||||
"scrypt": "^6.0.2" |
||||
} |
||||
}, |
||||
"node_modules/scryptsy": { |
||||
"version": "1.2.1", |
||||
"resolved": "https://registry.npmjs.org/scryptsy/-/scryptsy-1.2.1.tgz", |
||||
"integrity": "sha512-aldIRgMozSJ/Gl6K6qmJZysRP82lz83Wb42vl4PWN8SaLFHIaOzLPc9nUUW2jQN88CuGm5q5HefJ9jZ3nWSmTw==", |
||||
"dependencies": { |
||||
"pbkdf2": "^3.0.3" |
||||
} |
||||
}, |
||||
"node_modules/secp256k1": { |
||||
"version": "3.8.0", |
||||
"resolved": "https://registry.npmjs.org/secp256k1/-/secp256k1-3.8.0.tgz", |
||||
"integrity": "sha512-k5ke5avRZbtl9Tqx/SA7CbY3NF6Ro+Sj9cZxezFzuBlLDmyqPiL8hJJ+EmzD8Ig4LUDByHJ3/iPOVoRixs/hmw==", |
||||
"hasInstallScript": true, |
||||
"dependencies": { |
||||
"bindings": "^1.5.0", |
||||
"bip66": "^1.1.5", |
||||
"bn.js": "^4.11.8", |
||||
"create-hash": "^1.2.0", |
||||
"drbg.js": "^1.0.1", |
||||
"elliptic": "^6.5.2", |
||||
"nan": "^2.14.0", |
||||
"safe-buffer": "^5.1.2" |
||||
}, |
||||
"engines": { |
||||
"node": ">=4.0.0" |
||||
} |
||||
}, |
||||
"node_modules/sha.js": { |
||||
"version": "2.4.11", |
||||
"resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz", |
||||
"integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==", |
||||
"dependencies": { |
||||
"inherits": "^2.0.1", |
||||
"safe-buffer": "^5.0.1" |
||||
}, |
||||
"bin": { |
||||
"sha.js": "bin.js" |
||||
} |
||||
}, |
||||
"node_modules/string_decoder": { |
||||
"version": "1.3.0", |
||||
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", |
||||
"integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", |
||||
"dependencies": { |
||||
"safe-buffer": "~5.2.0" |
||||
} |
||||
}, |
||||
"node_modules/unorm": { |
||||
"version": "1.6.0", |
||||
"resolved": "https://registry.npmjs.org/unorm/-/unorm-1.6.0.tgz", |
||||
"integrity": "sha512-b2/KCUlYZUeA7JFUuRJZPUtr4gZvBh7tavtv4fvk4+KV9pfGiR6CQAQAWl49ZpR3ts2dk4FYkP7EIgDJoiOLDA==", |
||||
"engines": { |
||||
"node": ">= 0.4.0" |
||||
} |
||||
}, |
||||
"node_modules/util-deprecate": { |
||||
"version": "1.0.2", |
||||
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", |
||||
"integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" |
||||
}, |
||||
"node_modules/uuid": { |
||||
"version": "3.4.0", |
||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", |
||||
"integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", |
||||
"deprecated": "Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.", |
||||
"bin": { |
||||
"uuid": "bin/uuid" |
||||
} |
||||
} |
||||
}, |
||||
"dependencies": { |
||||
"@woop-js/utils": { |
||||
"version": "0.1.56", |
||||
"resolved": "https://registry.npmjs.org/@woop-js/utils/-/utils-0.1.56.tgz", |
||||
"integrity": "sha512-XoYYIMoK/mSxPkxFd25dY/wScIWWevoTrHoFdlFd8N7GWlilfdgQEF5vO+4BA6hyDJ4ryfdLnGc6W6Hz+5qs2A==", |
||||
"requires": { |
||||
"@types/bn.js": "^4.11.3", |
||||
"bn.js": "^4.11.8" |
||||
} |
||||
}, |
||||
"@types/bn.js": { |
||||
"version": "4.11.6", |
||||
"resolved": "https://registry.npmjs.org/@types/bn.js/-/bn.js-4.11.6.tgz", |
||||
"integrity": "sha512-pqr857jrp2kPuO9uRjZ3PwnJTjoQy+fcdxvBTvHm6dkmEL9q+hDD/2j/0ELOBPtPnS8LjCX0gI9nbl8lVkadpg==", |
||||
"requires": { |
||||
"@types/node": "*" |
||||
} |
||||
}, |
||||
"@types/node": { |
||||
"version": "14.11.2", |
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.11.2.tgz", |
||||
"integrity": "sha512-jiE3QIxJ8JLNcb1Ps6rDbysDhN4xa8DJJvuC9prr6w+1tIh+QAbYyNF3tyiZNLDBIuBCf4KEcV2UvQm/V60xfA==" |
||||
}, |
||||
"aes-js": { |
||||
"version": "3.1.2", |
||||
"resolved": "https://registry.npmjs.org/aes-js/-/aes-js-3.1.2.tgz", |
||||
"integrity": "sha512-e5pEa2kBnBOgR4Y/p20pskXI74UEz7de8ZGVo58asOtvSVG5YAbJeELPZxOmt+Bnz3rX753YKhfIn4X4l1PPRQ==" |
||||
}, |
||||
"base-x": { |
||||
"version": "3.0.8", |
||||
"resolved": "https://registry.npmjs.org/base-x/-/base-x-3.0.8.tgz", |
||||
"integrity": "sha512-Rl/1AWP4J/zRrk54hhlxH4drNxPJXYUaKffODVI53/dAsV4t9fBxyxYKAVPU1XBHxYwOWP9h9H0hM2MVw4YfJA==", |
||||
"requires": { |
||||
"safe-buffer": "^5.0.1" |
||||
} |
||||
}, |
||||
"bindings": { |
||||
"version": "1.5.0", |
||||
"resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", |
||||
"integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", |
||||
"requires": { |
||||
"file-uri-to-path": "1.0.0" |
||||
} |
||||
}, |
||||
"bip39": { |
||||
"version": "2.6.0", |
||||
"resolved": "https://registry.npmjs.org/bip39/-/bip39-2.6.0.tgz", |
||||
"integrity": "sha512-RrnQRG2EgEoqO24ea+Q/fftuPUZLmrEM3qNhhGsA3PbaXaCW791LTzPuVyx/VprXQcTbPJ3K3UeTna8ZnVl2sg==", |
||||
"requires": { |
||||
"create-hash": "^1.1.0", |
||||
"pbkdf2": "^3.0.9", |
||||
"randombytes": "^2.0.1", |
||||
"safe-buffer": "^5.0.1", |
||||
"unorm": "^1.3.3" |
||||
} |
||||
}, |
||||
"bip66": { |
||||
"version": "1.1.5", |
||||
"resolved": "https://registry.npmjs.org/bip66/-/bip66-1.1.5.tgz", |
||||
"integrity": "sha1-AfqHSHhcpwlV1QESF9GzE5lpyiI=", |
||||
"requires": { |
||||
"safe-buffer": "^5.0.1" |
||||
} |
||||
}, |
||||
"bn.js": { |
||||
"version": "4.11.8", |
||||
"resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.8.tgz", |
||||
"integrity": "sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA==" |
||||
}, |
||||
"brorand": { |
||||
"version": "1.1.0", |
||||
"resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz", |
||||
"integrity": "sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8=" |
||||
}, |
||||
"browserify-aes": { |
||||
"version": "1.2.0", |
||||
"resolved": "https://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz", |
||||
"integrity": "sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA==", |
||||
"requires": { |
||||
"buffer-xor": "^1.0.3", |
||||
"cipher-base": "^1.0.0", |
||||
"create-hash": "^1.1.0", |
||||
"evp_bytestokey": "^1.0.3", |
||||
"inherits": "^2.0.1", |
||||
"safe-buffer": "^5.0.1" |
||||
} |
||||
}, |
||||
"bs58": { |
||||
"version": "4.0.1", |
||||
"resolved": "https://registry.npmjs.org/bs58/-/bs58-4.0.1.tgz", |
||||
"integrity": "sha1-vhYedsNU9veIrkBx9j806MTwpCo=", |
||||
"requires": { |
||||
"base-x": "^3.0.2" |
||||
} |
||||
}, |
||||
"bs58check": { |
||||
"version": "2.1.2", |
||||
"resolved": "https://registry.npmjs.org/bs58check/-/bs58check-2.1.2.tgz", |
||||
"integrity": "sha512-0TS1jicxdU09dwJMNZtVAfzPi6Q6QeN0pM1Fkzrjn+XYHvzMKPU3pHVpva+769iNVSfIYWf7LJ6WR+BuuMf8cA==", |
||||
"requires": { |
||||
"bs58": "^4.0.0", |
||||
"create-hash": "^1.1.0", |
||||
"safe-buffer": "^5.1.2" |
||||
} |
||||
}, |
||||
"buffer-xor": { |
||||
"version": "1.0.3", |
||||
"resolved": "https://registry.npmjs.org/buffer-xor/-/buffer-xor-1.0.3.tgz", |
||||
"integrity": "sha1-JuYe0UIvtw3ULm42cp7VHYVf6Nk=" |
||||
}, |
||||
"cipher-base": { |
||||
"version": "1.0.4", |
||||
"resolved": "https://registry.npmjs.org/cipher-base/-/cipher-base-1.0.4.tgz", |
||||
"integrity": "sha512-Kkht5ye6ZGmwv40uUDZztayT2ThLQGfnj/T71N/XzeZeo3nf8foyW7zGTsPYkEya3m5f3cAypH+qe7YOrM1U2Q==", |
||||
"requires": { |
||||
"inherits": "^2.0.1", |
||||
"safe-buffer": "^5.0.1" |
||||
} |
||||
}, |
||||
"create-hash": { |
||||
"version": "1.2.0", |
||||
"resolved": "https://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz", |
||||
"integrity": "sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg==", |
||||
"requires": { |
||||
"cipher-base": "^1.0.1", |
||||
"inherits": "^2.0.1", |
||||
"md5.js": "^1.3.4", |
||||
"ripemd160": "^2.0.1", |
||||
"sha.js": "^2.4.0" |
||||
} |
||||
}, |
||||
"create-hmac": { |
||||
"version": "1.1.7", |
||||
"resolved": "https://registry.npmjs.org/create-hmac/-/create-hmac-1.1.7.tgz", |
||||
"integrity": "sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg==", |
||||
"requires": { |
||||
"cipher-base": "^1.0.3", |
||||
"create-hash": "^1.1.0", |
||||
"inherits": "^2.0.1", |
||||
"ripemd160": "^2.0.0", |
||||
"safe-buffer": "^5.0.1", |
||||
"sha.js": "^2.4.8" |
||||
} |
||||
}, |
||||
"drbg.js": { |
||||
"version": "1.0.1", |
||||
"resolved": "https://registry.npmjs.org/drbg.js/-/drbg.js-1.0.1.tgz", |
||||
"integrity": "sha1-Pja2xCs3BDgjzbwzLVjzHiRFSAs=", |
||||
"requires": { |
||||
"browserify-aes": "^1.0.6", |
||||
"create-hash": "^1.1.2", |
||||
"create-hmac": "^1.1.4" |
||||
} |
||||
}, |
||||
"elliptic": { |
||||
"version": "6.5.3", |
||||
"resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.3.tgz", |
||||
"integrity": "sha512-IMqzv5wNQf+E6aHeIqATs0tOLeOTwj1QKbRcS3jBbYkl5oLAserA8yJTT7/VyHUYG91PRmPyeQDObKLPpeS4dw==", |
||||
"requires": { |
||||
"bn.js": "^4.4.0", |
||||
"brorand": "^1.0.1", |
||||
"hash.js": "^1.0.0", |
||||
"hmac-drbg": "^1.0.0", |
||||
"inherits": "^2.0.1", |
||||
"minimalistic-assert": "^1.0.0", |
||||
"minimalistic-crypto-utils": "^1.0.0" |
||||
} |
||||
}, |
||||
"evp_bytestokey": { |
||||
"version": "1.0.3", |
||||
"resolved": "https://registry.npmjs.org/evp_bytestokey/-/evp_bytestokey-1.0.3.tgz", |
||||
"integrity": "sha512-/f2Go4TognH/KvCISP7OUsHn85hT9nUkxxA9BEWxFn+Oj9o8ZNLm/40hdlgSLyuOimsrTKLUMEorQexp/aPQeA==", |
||||
"requires": { |
||||
"md5.js": "^1.3.4", |
||||
"safe-buffer": "^5.1.1" |
||||
} |
||||
}, |
||||
"file-uri-to-path": { |
||||
"version": "1.0.0", |
||||
"resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", |
||||
"integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==" |
||||
}, |
||||
"hash-base": { |
||||
"version": "3.1.0", |
||||
"resolved": "https://registry.npmjs.org/hash-base/-/hash-base-3.1.0.tgz", |
||||
"integrity": "sha512-1nmYp/rhMDiE7AYkDw+lLwlAzz0AntGIe51F3RfFfEqyQ3feY2eI/NcwC6umIQVOASPMsWJLJScWKSSvzL9IVA==", |
||||
"requires": { |
||||
"inherits": "^2.0.4", |
||||
"readable-stream": "^3.6.0", |
||||
"safe-buffer": "^5.2.0" |
||||
} |
||||
}, |
||||
"hash.js": { |
||||
"version": "1.1.7", |
||||
"resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.7.tgz", |
||||
"integrity": "sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA==", |
||||
"requires": { |
||||
"inherits": "^2.0.3", |
||||
"minimalistic-assert": "^1.0.1" |
||||
} |
||||
}, |
||||
"hdkey": { |
||||
"version": "1.1.2", |
||||
"resolved": "https://registry.npmjs.org/hdkey/-/hdkey-1.1.2.tgz", |
||||
"integrity": "sha512-PTQ4VKu0oRnCrYfLp04iQZ7T2Cxz0UsEXYauk2j8eh6PJXCpbXuCFhOmtIFtbET0i3PMWmHN9J11gU8LEgUljQ==", |
||||
"requires": { |
||||
"bs58check": "^2.1.2", |
||||
"safe-buffer": "^5.1.1", |
||||
"secp256k1": "^3.0.1" |
||||
} |
||||
}, |
||||
"hmac-drbg": { |
||||
"version": "1.0.1", |
||||
"resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz", |
||||
"integrity": "sha1-0nRXAQJabHdabFRXk+1QL8DGSaE=", |
||||
"requires": { |
||||
"hash.js": "^1.0.3", |
||||
"minimalistic-assert": "^1.0.0", |
||||
"minimalistic-crypto-utils": "^1.0.1" |
||||
} |
||||
}, |
||||
"inherits": { |
||||
"version": "2.0.4", |
||||
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", |
||||
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" |
||||
}, |
||||
"js-sha3": { |
||||
"version": "0.8.0", |
||||
"resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.8.0.tgz", |
||||
"integrity": "sha512-gF1cRrHhIzNfToc802P800N8PpXS+evLLXfsVpowqmAFR9uwbi89WvXg2QspOmXL8QL86J4T1EpFu+yUkwJY3Q==" |
||||
}, |
||||
"md5.js": { |
||||
"version": "1.3.5", |
||||
"resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.5.tgz", |
||||
"integrity": "sha512-xitP+WxNPcTTOgnTJcrhM0xvdPepipPSf3I8EIpGKeFLjt3PlJLIDG3u8EX53ZIubkb+5U2+3rELYpEhHhzdkg==", |
||||
"requires": { |
||||
"hash-base": "^3.0.0", |
||||
"inherits": "^2.0.1", |
||||
"safe-buffer": "^5.1.2" |
||||
} |
||||
}, |
||||
"minimalistic-assert": { |
||||
"version": "1.0.1", |
||||
"resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz", |
||||
"integrity": "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==" |
||||
}, |
||||
"minimalistic-crypto-utils": { |
||||
"version": "1.0.1", |
||||
"resolved": "https://registry.npmjs.org/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz", |
||||
"integrity": "sha1-9sAMHAsIIkblxNmd+4x8CDsrWCo=" |
||||
}, |
||||
"nan": { |
||||
"version": "2.14.1", |
||||
"resolved": "https://registry.npmjs.org/nan/-/nan-2.14.1.tgz", |
||||
"integrity": "sha512-isWHgVjnFjh2x2yuJ/tj3JbwoHu3UC2dX5G/88Cm24yB6YopVgxvBObDY7n5xW6ExmFhJpSEQqFPvq9zaXc8Jw==" |
||||
}, |
||||
"pbkdf2": { |
||||
"version": "3.0.17", |
||||
"resolved": "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.0.17.tgz", |
||||
"integrity": "sha512-U/il5MsrZp7mGg3mSQfn742na2T+1/vHDCG5/iTI3X9MKUuYUZVLQhyRsg06mCgDBTd57TxzgZt7P+fYfjRLtA==", |
||||
"requires": { |
||||
"create-hash": "^1.1.2", |
||||
"create-hmac": "^1.1.4", |
||||
"ripemd160": "^2.0.1", |
||||
"safe-buffer": "^5.0.1", |
||||
"sha.js": "^2.4.8" |
||||
} |
||||
}, |
||||
"randombytes": { |
||||
"version": "2.1.0", |
||||
"resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", |
||||
"integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", |
||||
"requires": { |
||||
"safe-buffer": "^5.1.0" |
||||
} |
||||
}, |
||||
"readable-stream": { |
||||
"version": "3.6.0", |
||||
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", |
||||
"integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", |
||||
"requires": { |
||||
"inherits": "^2.0.3", |
||||
"string_decoder": "^1.1.1", |
||||
"util-deprecate": "^1.0.1" |
||||
} |
||||
}, |
||||
"ripemd160": { |
||||
"version": "2.0.2", |
||||
"resolved": "https://registry.npmjs.org/ripemd160/-/ripemd160-2.0.2.tgz", |
||||
"integrity": "sha512-ii4iagi25WusVoiC4B4lq7pbXfAp3D9v5CwfkY33vffw2+pkDjY1D8GaN7spsxvCSx8dkPqOZCEZyfxcmJG2IA==", |
||||
"requires": { |
||||
"hash-base": "^3.0.0", |
||||
"inherits": "^2.0.1" |
||||
} |
||||
}, |
||||
"safe-buffer": { |
||||
"version": "5.2.0", |
||||
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.0.tgz", |
||||
"integrity": "sha512-fZEwUGbVl7kouZs1jCdMLdt95hdIv0ZeHg6L7qPeciMZhZ+/gdesW4wgTARkrFWEpspjEATAzUGPG8N2jJiwbg==" |
||||
}, |
||||
"scrypt.js": { |
||||
"version": "0.3.0", |
||||
"resolved": "https://registry.npmjs.org/scrypt.js/-/scrypt.js-0.3.0.tgz", |
||||
"integrity": "sha512-42LTc1nyFsyv/o0gcHtDztrn+aqpkaCNt5Qh7ATBZfhEZU7IC/0oT/qbBH+uRNoAPvs2fwiOId68FDEoSRA8/A==", |
||||
"requires": { |
||||
"scrypt": "^6.0.2", |
||||
"scryptsy": "^1.2.1" |
||||
} |
||||
}, |
||||
"scryptsy": { |
||||
"version": "1.2.1", |
||||
"resolved": "https://registry.npmjs.org/scryptsy/-/scryptsy-1.2.1.tgz", |
||||
"integrity": "sha512-aldIRgMozSJ/Gl6K6qmJZysRP82lz83Wb42vl4PWN8SaLFHIaOzLPc9nUUW2jQN88CuGm5q5HefJ9jZ3nWSmTw==", |
||||
"requires": { |
||||
"pbkdf2": "^3.0.3" |
||||
} |
||||
}, |
||||
"secp256k1": { |
||||
"version": "3.8.0", |
||||
"resolved": "https://registry.npmjs.org/secp256k1/-/secp256k1-3.8.0.tgz", |
||||
"integrity": "sha512-k5ke5avRZbtl9Tqx/SA7CbY3NF6Ro+Sj9cZxezFzuBlLDmyqPiL8hJJ+EmzD8Ig4LUDByHJ3/iPOVoRixs/hmw==", |
||||
"requires": { |
||||
"bindings": "^1.5.0", |
||||
"bip66": "^1.1.5", |
||||
"bn.js": "^4.11.8", |
||||
"create-hash": "^1.2.0", |
||||
"drbg.js": "^1.0.1", |
||||
"elliptic": "^6.5.2", |
||||
"nan": "^2.14.0", |
||||
"safe-buffer": "^5.1.2" |
||||
} |
||||
}, |
||||
"sha.js": { |
||||
"version": "2.4.11", |
||||
"resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz", |
||||
"integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==", |
||||
"requires": { |
||||
"inherits": "^2.0.1", |
||||
"safe-buffer": "^5.0.1" |
||||
} |
||||
}, |
||||
"string_decoder": { |
||||
"version": "1.3.0", |
||||
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", |
||||
"integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", |
||||
"requires": { |
||||
"safe-buffer": "~5.2.0" |
||||
} |
||||
}, |
||||
"unorm": { |
||||
"version": "1.6.0", |
||||
"resolved": "https://registry.npmjs.org/unorm/-/unorm-1.6.0.tgz", |
||||
"integrity": "sha512-b2/KCUlYZUeA7JFUuRJZPUtr4gZvBh7tavtv4fvk4+KV9pfGiR6CQAQAWl49ZpR3ts2dk4FYkP7EIgDJoiOLDA==" |
||||
}, |
||||
"util-deprecate": { |
||||
"version": "1.0.2", |
||||
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", |
||||
"integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" |
||||
}, |
||||
"uuid": { |
||||
"version": "3.4.0", |
||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", |
||||
"integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==" |
||||
} |
||||
} |
||||
} |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue