Skip to content

Commit

Permalink
Merge branch 'develop' into 'master'
Browse files Browse the repository at this point in the history
develop

See merge request papers/airgap/airgap-coin-lib!641
  • Loading branch information
godenzim committed Jan 18, 2023
2 parents 2ed4db2 + c1733d1 commit ae83cc3
Show file tree
Hide file tree
Showing 1,634 changed files with 109,241 additions and 37,305 deletions.
52 changes: 51 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,60 @@ WORKDIR /app
# Install app dependencies
COPY package.json /app
COPY package-lock.json /app
COPY scripts /app/scripts

COPY packages/core/package.json /app/packages/core/
COPY packages/core/package-lock.json /app/packages/core/
COPY packages/core/scripts /app/packages/core/scripts
COPY scripts /app/scripts

COPY packages/aeternity/package.json /app/packages/aeternity/
COPY packages/aeternity/package-lock.json /app/packages/aeternity/
COPY packages/aeternity/scripts /app/packages/aeternity/scripts

COPY packages/astar/package.json /app/packages/astar/
COPY packages/astar/package-lock.json /app/packages/astar/
COPY packages/astar/scripts /app/packages/astar/scripts

COPY packages/bitcoin/package.json /app/packages/bitcoin/
COPY packages/bitcoin/package-lock.json /app/packages/bitcoin/
COPY packages/bitcoin/scripts /app/packages/bitcoin/scripts

COPY packages/cosmos/package.json /app/packages/cosmos/
COPY packages/cosmos/package-lock.json /app/packages/cosmos/
COPY packages/cosmos/scripts /app/packages/cosmos/scripts

COPY packages/ethereum/package.json /app/packages/ethereum/
COPY packages/ethereum/package-lock.json /app/packages/ethereum/
COPY packages/ethereum/scripts /app/packages/ethereum/scripts

COPY packages/groestlcoin/package.json /app/packages/groestlcoin/
COPY packages/groestlcoin/package-lock.json /app/packages/groestlcoin/
COPY packages/groestlcoin/scripts /app/packages/groestlcoin/scripts

COPY packages/module-kit/package.json /app/packages/module-kit/
COPY packages/module-kit/package-lock.json /app/packages/module-kit/
COPY packages/module-kit/scripts /app/packages/module-kit/scripts

COPY packages/moonbeam/package.json /app/packages/moonbeam/
COPY packages/moonbeam/package-lock.json /app/packages/moonbeam/
COPY packages/moonbeam/scripts /app/packages/moonbeam/scripts

COPY packages/polkadot/package.json /app/packages/polkadot/
COPY packages/polkadot/package-lock.json /app/packages/polkadot/
COPY packages/polkadot/scripts /app/packages/polkadot/scripts

COPY packages/substrate/package.json /app/packages/substrate/
COPY packages/substrate/package-lock.json /app/packages/substrate/
COPY packages/substrate/scripts /app/packages/substrate/scripts

COPY packages/tezos/package.json /app/packages/tezos/
COPY packages/tezos/package-lock.json /app/packages/tezos/
COPY packages/tezos/scripts /app/packages/tezos/scripts

COPY packages/serializer/package.json /app/packages/serializer/
COPY packages/serializer/package-lock.json /app/packages/serializer/
COPY packages/serializer/scripts /app/packages/serializer/scripts

COPY lerna.json /app

# install dependencies
Expand Down
9 changes: 5 additions & 4 deletions examples/custom/protocols/cosmos/cosmos-examples.ts
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)
})
4 changes: 2 additions & 2 deletions examples/custom/protocols/cosmos/get-keys.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CosmosProtocol } from '../../../../packages/core/src'
import { CosmosProtocol } from '../../../../packages/cosmos/src'
import * as BIP39 from '../../../../packages/core/src/dependencies/src/bip39-2.5.0/index'

const protocol: CosmosProtocol = new CosmosProtocol()
Expand All @@ -7,5 +7,5 @@ const mnemonic: string = 'spell device they juice trial skirt amazing boat badge

const seed: string = BIP39.mnemonicToSeed(mnemonic).toString('hex')

console.log(protocol.getPrivateKeyFromHexSecret(seed, protocol.standardDerivationPath).toString('hex'))
console.log(protocol.getPrivateKeyFromHexSecret(seed, protocol.standardDerivationPath))
console.log(protocol.getPublicKeyFromHexSecret(seed, protocol.standardDerivationPath))
64 changes: 34 additions & 30 deletions examples/custom/protocols/cosmos/prepare-transaction.ts
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)
}
})()
2 changes: 1 addition & 1 deletion examples/custom/protocols/ethereum/eth-utils.ts
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
2 changes: 1 addition & 1 deletion examples/custom/protocols/ethereum/ethereum-samples.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { EthereumProtocol } from '../../../../packages/core/src/protocols/ethereum/EthereumProtocol'
import { EthereumProtocol } from '../../../../packages/ethereum/src'

const address = '0x73494BCb0865a72fD03cb3242e4C7b48688c0fEb'
const protocol = new EthereumProtocol()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { generateId, IACMessageDefinitionObject, IACMessageType, Serializer } from '../../../../packages/core/src'
import { SubstrateAddress } from '../../../../packages/core/src/protocols/substrate/helpers/data/account/SubstrateAddress'
import { SubstrateNetwork } from '../../../../packages/core/src/protocols/substrate/SubstrateNetwork'
import { generateId, IACMessageDefinitionObject, IACMessageType, Serializer } from '../../../../packages/serializer/src'
import { SubstrateAddress, SubstrateNetwork } from '../../../../packages/substrate/src'
import { MainProtocolSymbols } from '../../../../packages/core/src/utils/ProtocolSymbols'

const address: string = '12QceCDMHcK6qgnxLJsMBQPLAA6iX8WCuSx7dChcsNNnBtKg'
Expand Down Expand Up @@ -31,4 +30,4 @@ getPubkeyFromAddress(address).then(async (pubkey) => {

// Generate QR here: https://kazuhikoarase.github.io/qrcode-generator/js/demo/
console.log(result[0])
})
})
2 changes: 1 addition & 1 deletion examples/custom/protocols/tezos/baker-info.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// tslint:disable:no-console

import { BakerInfo, TezosKtProtocol } from '../../../../packages/core/src'
import { BakerInfo, TezosKtProtocol } from '../../../../packages/tezos/src'

const kt: TezosKtProtocol = new TezosKtProtocol()

Expand Down
11 changes: 2 additions & 9 deletions examples/custom/protocols/tezos/fa2-smart-contract.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
import {
TezosFA2Protocol,
TezosProtocolNetwork,
TezosFA2ProtocolConfig,
SubProtocolSymbols,
TezosFA2ProtocolOptions,
NetworkType
} from '../../../../packages/core/src'

import { NetworkType, SubProtocolSymbols } from '../../../../packages/core/src'
import { TezosFA2Protocol, TezosProtocolNetwork, TezosFA2ProtocolConfig, TezosFA2ProtocolOptions } from '../../../../packages/tezos/src'
;(async () => {
const network = new TezosProtocolNetwork('edonet', NetworkType.TESTNET, 'https://tezos-edonet-node.qa.gke.papers.tech')
const config = new TezosFA2ProtocolConfig(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IACMessageDefinitionObject, IACMessageType, Serializer } from '../../../../packages/core/src'
import { IACMessageDefinitionObject, IACMessageType, Serializer } from '../../../../packages/serializer/src'
import Axios from '../../../../packages/core/src/dependencies/src/axios-0.19.0'
import * as bs58check from '../../../../packages/core/src/dependencies/src/bs58check-2.1.2'
import { MainProtocolSymbols } from '../../../../packages/core/src/utils/ProtocolSymbols'
Expand Down
4 changes: 2 additions & 2 deletions examples/custom/protocols/tezos/prepare-operations.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { TezosProtocol } from '../../../../packages/core/src/index'
import { TezosOperationType } from '../../../../packages/core/src/protocols/tezos/types/TezosOperationType'
import { TezosProtocol } from '../../../../packages/tezos/src'
import { TezosOperationType } from '../../../../packages/tezos/src/protocol/types/TezosOperationType'

const tezosProtocol = new TezosProtocol()

Expand Down
16 changes: 11 additions & 5 deletions examples/custom/protocols/tezos/prepare-transaction.ts
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))
2 changes: 1 addition & 1 deletion examples/custom/protocols/tezos/send.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TezosProtocol } from '../../../../packages/core/src'
import { TezosProtocol } from '../../../../packages/tezos/src'
import { getTransactionDetailsFromSigned } from '../../../generic/functions/get-transaction-details'
import { send } from '../../../generic/functions/send-transaction'

Expand Down
10 changes: 5 additions & 5 deletions examples/custom/protocols/tezos/tezosContractCalls.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// import { TezosFAProtocol } from '../../../../packages/core/src'
// import { TezosKolibriUSD } from '../../../../packages/core/src'
import { TezosBTC } from '../../../../packages/core/src'
// import { TezosUSD } from '../../../../packages/core/src'
// import { TezosStaker } from '../../../../packages/core/src'
// import { TezosFAProtocol } from '../../../../packages/tezos/src'
// import { TezosKolibriUSD } from '../../../../packages/tezos/src'
import { TezosBTC } from '../../../../packages/tezos/src'
// import { TezosUSD } from '../../../../packages/tezos/src'
// import { TezosStaker } from '../../../../packages/tezos/src'

const contract = new TezosBTC()
// const contract = new TezosKolibriUSD()
Expand Down
7 changes: 4 additions & 3 deletions examples/custom/protocols/tezos/unforge.ts
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))
17 changes: 7 additions & 10 deletions examples/generic/all.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
const mnemonic: string =
'move fit muffin gauge initial supreme one language grace keep myth trick sun eyebrow radio movie marriage height water sad faint inherit end try'

import { AeternityProtocol } from '../../packages/aeternity/src'
import { BitcoinProtocol } from '../../packages/bitcoin/src'
import { CosmosProtocol } from '../../packages/cosmos/src'
import { EthereumProtocol } from '../../packages/ethereum/src'
import { GroestlcoinProtocol } from '../../packages/groestlcoin/src'
import { KusamaProtocol, PolkadotProtocol } from '../../packages/polkadot/src'
import { TezosProtocol } from '../../packages/tezos/src'
// import { writeFile } from 'fs'
import {
AeternityProtocol,
BitcoinProtocol,
CosmosProtocol,
EthereumProtocol,
GroestlcoinProtocol,
KusamaProtocol,
PolkadotProtocol,
TezosProtocol
} from '../../packages/core/src'

import { generateIACCode } from './functions/generate-iac-code'

Expand Down
4 changes: 2 additions & 2 deletions examples/generic/functions/generate-iac-code.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// tslint:disable:no-console
// tslint:disable:no-any

import { IACMessageDefinitionObject, IACMessageType, ICoinProtocol, Serializer } from '../../../packages/core/src'
import { generateId } from '../../../packages/core/src/serializer/utils/generateId'
import { IACMessageDefinitionObject, IACMessageType, Serializer, generateId } from '../../../packages/serializer/src'
import { MainProtocolSymbols } from '../../../packages/core/src/utils/ProtocolSymbols'
import { ICoinProtocol } from '../../../packages/core/src'

export const generateIACCode: (
protocol: ICoinProtocol,
Expand Down
3 changes: 2 additions & 1 deletion examples/generic/tezos.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// tslint:disable:no-console

import { ICoinProtocol, TezosProtocol } from '../../packages/core/src'
import { ICoinProtocol } from '../../packages/core/src'
import { TezosProtocol } from '../../packages/tezos/src'

import { all } from './functions/all'
import { decryptAES } from './functions/decrypt-aes'
Expand Down
5 changes: 1 addition & 4 deletions examples/serializer/create-qr.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import { IACMessageType } from '../../packages/core/src/serializer-v3/interfaces'
import { IACMessageDefinitionObject } from '../../packages/core/src/serializer-v3/message'
import { SerializerV3 } from '../../packages/core/src/serializer-v3/serializer'
import { generateId } from '../../packages/core/src/serializer-v3/utils/generateId'
import { MainProtocolSymbols } from '../../packages/core/src/utils/ProtocolSymbols'
import { generateId, IACMessageDefinitionObject, IACMessageType, SerializerV3 } from '../../packages/serializer/src'

const json: IACMessageDefinitionObject = {
type: IACMessageType.TransactionSignRequest,
Expand Down
3 changes: 1 addition & 2 deletions examples/serializer/deserialize.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// tslint:disable:no-console

import { IACMessageDefinitionObject } from '../../packages/core/src/serializer/message'
import { Serializer } from '../../packages/core/src/serializer/serializer'
import { IACMessageDefinitionObject, Serializer } from '../../packages/serializer/src'

const urls: string[] = [
'UV9La4L9iqSztUbkKAE6tGeeTixJuam5wNaybVk3fJQYaZh6hUiRpXeXRzJ9TCXTuptahAx6WM97VH7VB7NjU9aQgmbN9MogwhZSyW6e7k2B9m8AGxLqBdENyp8Vq22EYpeb1xTgNfaSfwDwsJWJURiZvPat1bCTJj7iLWKBtvNqFjtgVABAbmk2RWjogXtwyZVfaENYLR3PP8WAhJZZ6dHM4WJA7VaNb22rreiS4td8vMA4e2mvUfJ1gB18inJY1DvY1JyeJUnujc2XBmAYTuAeoSGwxQkpUnScnucmzsk1xJik9FYztmZi1T86AS8znrMKZhwSGrzTCXVk8DnYhwp4bm3YhPzVLLbpvHYev1Nk3LNWtyNt9HjCScyQBYN9365kyWM6L28cemfqZzidPXzNcZnibgnvsXX6k1h6v77yFCbg5JXqk7UeaY4r7nMGhX1JuBvcSsEahDXMAmfJVo3NFZVCj4TKKZXsLZ1ByPVEgz2cyUoJjn13G5X8SQCPBWam4MBm17dQcJq9N33HnWhn7nGncjVat2gUEKXc94ZV'
Expand Down
4 changes: 1 addition & 3 deletions examples/serializer/message-sign.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { IACMessageType } from '../../packages/core/src/serializer/interfaces'
import { IACMessageDefinitionObject } from '../../packages/core/src/serializer/message'
import { Serializer } from '../../packages/core/src/serializer/serializer'
import { IACMessageDefinitionObject, IACMessageType, Serializer } from '../../packages/serializer/src'

const serializeAndDeserialize = async (messages: IACMessageDefinitionObject[], size: number) => {
const serializer: Serializer = new Serializer()
Expand Down
Loading

0 comments on commit ae83cc3

Please sign in to comment.