-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into 'master'
develop See merge request papers/airgap/airgap-coin-lib!641
- Loading branch information
Showing
1,634 changed files
with
109,241 additions
and
37,305 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,20 @@ | ||
import { CosmosProtocol } from '../../../../packages/core/src/protocols/cosmos/CosmosProtocol' | ||
import { CosmosProtocol } from '../../../../packages/cosmos/src' | ||
|
||
const mnemonic = | ||
'sick protect below book devote mention juice neck tent wrong fun either phone omit mango vacuum hedgehog run educate flag hundred famous duck garbage' | ||
const cosmos = new CosmosProtocol() | ||
|
||
const keyPair = cosmos.generateKeyPair(mnemonic) | ||
const pubKey = keyPair.publicKey.toString('hex') | ||
const privKey = keyPair.privateKey.toString('hex') | ||
cosmos.getAddressFromPublicKey(pubKey).then((address) => { | ||
cosmos | ||
.prepareTransactionFromPublicKey(pubKey, [address.getValue()], ['0'], cosmos.feeDefaults.medium, { memo: 'testing' }) | ||
.prepareTransactionFromPublicKey(pubKey, [address.address], ['0'], cosmos.feeDefaults.medium, { memo: 'testing' }) | ||
.then((transaction) => { | ||
cosmos.signWithPrivateKey(keyPair.privateKey, transaction).then((signed) => { | ||
cosmos.signWithPrivateKey(privKey, transaction).then((signed) => { | ||
console.log('Signed Transaction:') | ||
console.log(signed) | ||
}) | ||
}) | ||
cosmos.getBalanceOfAddresses([address.getValue()]).then(console.log).catch(console.error) | ||
cosmos.getBalanceOfAddresses([privKey]).then(console.log).catch(console.error) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,42 @@ | ||
import { CosmosProtocol, IACMessageDefinitionObject, IACMessageType, MainProtocolSymbols, Serializer } from '../../../../packages/core/src' | ||
import { MainProtocolSymbols } from '../../../../packages/core/src' | ||
import BigNumber from '../../../../packages/core/src/dependencies/src/bignumber.js-9.0.0/bignumber' | ||
import * as BIP39 from '../../../../packages/core/src/dependencies/src/bip39-2.5.0/index' | ||
import { CosmosProtocol } from '../../../../packages/cosmos/src' | ||
import { IACMessageDefinitionObject, IACMessageType, Serializer } from '../../../../packages/serializer/src' | ||
|
||
const mnemonic: string = 'spell device they juice trial skirt amazing boat badge steak usage february virus art survey' | ||
|
||
const seed: string = BIP39.mnemonicToSeed(mnemonic).toString('hex') | ||
const seed: string = BIP39.mnemonicToSeed(mnemonic).toString('hex')(async () => { | ||
try { | ||
const protocol = new CosmosProtocol() | ||
// const secKey = await protocol.getPrivateKeyFromHexSecret(seed, protocol.standardDerivationPath) | ||
const pubKey = await protocol.getPublicKeyFromHexSecret(seed, protocol.standardDerivationPath) | ||
const address = await protocol.getAddressFromPublicKey(pubKey) | ||
let availableBalance = await protocol.getAvailableBalanceOfAddresses([address.address]) | ||
availableBalance = new BigNumber(availableBalance).minus(10000).toFixed() | ||
const transaction = await protocol.prepareTransactionFromPublicKey( | ||
pubKey, | ||
['cosmos1w3mea9ghfdc3r7ax45mehl2tcqw9p0vnlhl0p6'], | ||
[availableBalance], | ||
new BigNumber(protocol.feeDefaults.medium).shiftedBy(protocol.decimals).toFixed() | ||
) | ||
console.log(transaction) | ||
|
||
(async () => { | ||
try { | ||
const protocol = new CosmosProtocol() | ||
// const secKey = await protocol.getPrivateKeyFromHexSecret(seed, protocol.standardDerivationPath) | ||
const pubKey = await protocol.getPublicKeyFromHexSecret(seed, protocol.standardDerivationPath) | ||
const address = await protocol.getAddressFromPublicKey(pubKey) | ||
let availableBalance = await protocol.getAvailableBalanceOfAddresses([address]) | ||
availableBalance = (new BigNumber(availableBalance)).minus(10000).toFixed() | ||
const transaction = await protocol.prepareTransactionFromPublicKey(pubKey, ['cosmos1w3mea9ghfdc3r7ax45mehl2tcqw9p0vnlhl0p6'], [availableBalance], new BigNumber(protocol.feeDefaults.medium).shiftedBy(protocol.decimals).toFixed()) | ||
console.log(transaction) | ||
|
||
const signTransactionRequest: IACMessageDefinitionObject = { | ||
id: 'asdfdfgsdfgsdfgsdfg', | ||
type: IACMessageType.TransactionSignRequest, | ||
protocol: MainProtocolSymbols.COSMOS, | ||
payload: { | ||
transaction: transaction, | ||
publicKey: '1', | ||
callbackURL: '2' | ||
} | ||
const signTransactionRequest: IACMessageDefinitionObject = { | ||
id: 'asdfdfgsdfgsdfgsdfg', | ||
type: IACMessageType.TransactionSignRequest, | ||
protocol: MainProtocolSymbols.COSMOS, | ||
payload: { | ||
transaction: transaction, | ||
publicKey: '1', | ||
callbackURL: '2' | ||
} | ||
|
||
const serializer = new Serializer() | ||
const result = serializer.serialize([signTransactionRequest]) | ||
console.log(result) | ||
|
||
} catch (error) { | ||
console.log(error) | ||
} | ||
})() | ||
|
||
const serializer = new Serializer() | ||
const result = serializer.serialize([signTransactionRequest]) | ||
console.log(result) | ||
} catch (error) { | ||
console.log(error) | ||
} | ||
})() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
// tslint:disable:no-any | ||
// tslint:disable:no-console | ||
|
||
import { EthereumUtils } from '../../../../packages/core/src/protocols/ethereum/utils/utils' | ||
import { EthereumUtils } from '../../../../packages/ethereum/src/protocol/utils/utils' | ||
|
||
console.log(EthereumUtils.sha3('test')) // 0x9c22ff5f21f0b81b113e63f7db6da94fedef11b2119b4088b89664fb9a3cb658 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,18 @@ | ||
import { TezosProtocol } from '../../../../packages/core/src/index' | ||
import { TezosProtocol } from '../../../../packages/tezos/src' | ||
|
||
const tezosProtocol = new TezosProtocol() | ||
|
||
const pubKey = '700d993c90aa176d3513d32c8ba411258631d8b15856dbec7b1b45398092c718' | ||
|
||
tezosProtocol.prepareTransactionFromPublicKey(pubKey, ['tz1MJx9vhaNRSimcuXPK2rW4fLccQnDAnVKJ'], ['1'], '0.001320').then(res => { | ||
tezosProtocol | ||
.prepareTransactionFromPublicKey(pubKey, ['tz1MJx9vhaNRSimcuXPK2rW4fLccQnDAnVKJ'], ['1'], '0.001320') | ||
.then((res) => { | ||
console.log(res) | ||
tezosProtocol.getTransactionDetails({publicKey: pubKey, transaction: res}).then(tx => { | ||
tezosProtocol | ||
.getTransactionDetails({ publicKey: pubKey, transaction: res }) | ||
.then((tx) => { | ||
console.log(tx) | ||
}).catch(error => console.error('error1', error)) | ||
}).catch(error => console.error('error2', error)) | ||
}) | ||
.catch((error) => console.error('error1', error)) | ||
}) | ||
.catch((error) => console.error('error2', error)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
import { TezosProtocol } from "../../../../packages/core/src" | ||
import { TezosProtocol } from '../../../../packages/tezos/src' | ||
|
||
const rawForged = "4393ee10fb3f22106d470837bb1a0fa3ca90573902ca07c5a5d874050282aa796c00bf97f5f1dbfd6ada0cf986d0a812f1bf0a572abcb817958139997800e8070000bf97f5f1dbfd6ada0cf986d0a812f1bf0a572abc00" | ||
const rawForged = | ||
'4393ee10fb3f22106d470837bb1a0fa3ca90573902ca07c5a5d874050282aa796c00bf97f5f1dbfd6ada0cf986d0a812f1bf0a572abcb817958139997800e8070000bf97f5f1dbfd6ada0cf986d0a812f1bf0a572abc00' | ||
|
||
const protocol = new TezosProtocol() | ||
|
||
console.log(protocol.unforgeUnsignedTezosWrappedOperation(rawForged)) | ||
console.log(protocol.unforgeUnsignedTezosWrappedOperation(rawForged)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.