diff --git a/apps/extension/package.json b/apps/extension/package.json index 25ad97c4859..d8335ae03a4 100644 --- a/apps/extension/package.json +++ b/apps/extension/package.json @@ -30,7 +30,7 @@ "dependencies": { "@cosmjs/encoding": "^0.29.0", "@dao-xyz/borsh": "^5.1.5", - "@ledgerhq/hw-transport": "^6.28.3", + "@ledgerhq/hw-transport": "^6.28.2", "@ledgerhq/hw-transport-webhid": "^6.27.14", "@ledgerhq/hw-transport-webusb": "^6.27.14", "@namada/chains": "0.1.0", diff --git a/apps/extension/src/App/Accounts/AccountListing.tsx b/apps/extension/src/App/Accounts/AccountListing.tsx index 39f06fd8ad1..6894d1ba1cc 100644 --- a/apps/extension/src/App/Accounts/AccountListing.tsx +++ b/apps/extension/src/App/Accounts/AccountListing.tsx @@ -40,7 +40,7 @@ const isChild = (type: AccountType, path: Bip44Path): boolean => { // with a path that isn't the default path (/0'/0/0). This is for display // purposes only. If the sum of the path components is greater than // zero, it is a child. - const { account, change, index = 0 } = path; + const { account, change, index } = path; return account + change + index > 0; } @@ -49,13 +49,12 @@ const isChild = (type: AccountType, path: Bip44Path): boolean => { const formatDerivationPath = ( isChildAccount: boolean, - { account, change, index = 0 }: Bip44Path, + { account, change, index }: Bip44Path, type: AccountType ): string => isChildAccount - ? `/${account}'/${ - type !== AccountType.Mnemonic ? `${change}/` : "" - }${index}` + ? `/${account}'/${type !== AccountType.Mnemonic ? `${change}/` : "" + }${index}` : ""; const AccountListing = ({ account, parentAlias }: Props): JSX.Element => { diff --git a/apps/extension/src/App/Accounts/AddAccount.tsx b/apps/extension/src/App/Accounts/AddAccount.tsx index d094b7cc66b..44365146e46 100644 --- a/apps/extension/src/App/Accounts/AddAccount.tsx +++ b/apps/extension/src/App/Accounts/AddAccount.tsx @@ -108,7 +108,7 @@ const findNextIndex = ( accounts .filter((account) => account.type === accountType) .forEach((account) => { - const { index = 0 } = account.path; + const { index } = account.path; maxIndex = index + 1; }); @@ -402,9 +402,8 @@ const AddAccount: React.FC = ({ Derivation path:{" "} - {`${parentDerivationPath}${ - isTransparent ? `${change}/` : "" - }${index}`} + {`${parentDerivationPath}${isTransparent ? `${change}/` : "" + }${index}`} {validation} diff --git a/apps/extension/src/Setup/Ledger/Steps/LedgerConnect/LedgerConnect.tsx b/apps/extension/src/Setup/Ledger/Steps/LedgerConnect/LedgerConnect.tsx index 7c0f4e16119..b406f3786ef 100644 --- a/apps/extension/src/Setup/Ledger/Steps/LedgerConnect/LedgerConnect.tsx +++ b/apps/extension/src/Setup/Ledger/Steps/LedgerConnect/LedgerConnect.tsx @@ -37,9 +37,15 @@ export const LedgerConnect: React.FC = () => { } const { address, publicKey } = await ledger.getAddressAndPublicKey(); + navigate( formatRouterPath([TopLevelRoute.Ledger, LedgerConnectRoute.Import]), - { state: { address, publicKey } } + { + state: { + address, + publicKey, + }, + } ); } catch (e) { handleError(e); diff --git a/apps/extension/src/background/keyring/keyring.ts b/apps/extension/src/background/keyring/keyring.ts index 6d9b8668b43..d27844746b6 100644 --- a/apps/extension/src/background/keyring/keyring.ts +++ b/apps/extension/src/background/keyring/keyring.ts @@ -1,5 +1,3 @@ -import BigNumber from "bignumber.js"; - import { deserialize } from "@dao-xyz/borsh"; import { chains } from "@namada/chains"; @@ -180,7 +178,11 @@ export class KeyRing { const mnemonic = Mnemonic.from_phrase(phrase); const seed = mnemonic.to_seed(); const { coinType } = chains[this.chainId].bip44; - const path = { account: 0, change: 0, index: 0 }; + const path = { + account: 0, + change: 0, + index: 0, + }; const bip44Path = makeBip44PathArray(coinType, path); const hdWallet = new HDWallet(seed); const key = hdWallet.derive(new Uint32Array(bip44Path)); @@ -251,7 +253,7 @@ export class KeyRing { const text = readStringPointer(privateKey, this.cryptoMemory); const address = new Address(text).implicit(); - const { account, change, index = 0 } = path; + const { account, change, index } = path; const id = generateId( UUID_NAMESPACE, "account", @@ -278,7 +280,7 @@ export class KeyRing { path: Bip44Path, parentId: string ): DerivedAccountInfo { - const { index = 0 } = path; + const { index } = path; const id = generateId(UUID_NAMESPACE, "shielded-account", parentId, index); const zip32 = new ShieldedHDWallet(seed); const account = zip32.derive_to_serialized_keys(index); @@ -308,58 +310,58 @@ export class KeyRing { }; } - private async *getAddressWithBalance( - seed: VecU8Pointer, - parentId: string, - type: AccountType - ): AsyncGenerator< - { - path: Bip44Path; - info: DerivedAccountInfo; - }, - void, - void - > { - let index = 0; - let emptyBalanceCount = 0; - const deriveFn = ( - type === AccountType.PrivateKey - ? this.deriveTransparentAccount - : this.deriveShieldedAccount - ).bind(this); - - const get = async ( - index: number - ): Promise<{ - path: Bip44Path; - info: DerivedAccountInfo; - balances: [string, string][]; - }> => { - // Cloning the seed, otherwise it gets zeroized in deriveTransparentAccount - const seedClone = seed.clone(); - const path = { account: 0, change: 0, index }; - const accountInfo = deriveFn(seedClone, path, parentId); - const balances: [string, string][] = await this.query.query_balance( - accountInfo.owner - ); - - return { path, info: accountInfo, balances }; - }; - - while (index < 999999999 && emptyBalanceCount < 20) { - const { path, info, balances } = await get(index++); - const hasBalance = balances.some(([, value]) => { - return !new BigNumber(value).isZero(); - }); - - if (hasBalance) { - emptyBalanceCount = 0; - yield { path, info }; - } else { - emptyBalanceCount++; - } - } - } + // private async *getAddressWithBalance( + // seed: VecU8Pointer, + // parentId: string, + // type: AccountType + // ): AsyncGenerator< + // { + // path: Bip44Path; + // info: DerivedAccountInfo; + // }, + // void, + // void + // > { + // let index = 0; + // let emptyBalanceCount = 0; + // const deriveFn = ( + // type === AccountType.PrivateKey + // ? this.deriveTransparentAccount + // : this.deriveShieldedAccount + // ).bind(this); + // + // const get = async ( + // index: number + // ): Promise<{ + // path: Bip44Path; + // info: DerivedAccountInfo; + // balances: [string, string][]; + // }> => { + // // Cloning the seed, otherwise it gets zeroized in deriveTransparentAccount + // const seedClone = seed.clone(); + // const path = { account: 0, change: 0, index }; + // const accountInfo = deriveFn(seedClone, path, parentId); + // const balances: [string, string][] = await this.query.query_balance( + // accountInfo.owner + // ); + // + // return { path, info: accountInfo, balances }; + // }; + // + // while (index < 999999999 && emptyBalanceCount < 20) { + // const { path, info, balances } = await get(index++); + // const hasBalance = balances.some(([, value]) => { + // return !new BigNumber(value).isZero(); + // }); + // + // if (hasBalance) { + // emptyBalanceCount = 0; + // yield { path, info }; + // } else { + // emptyBalanceCount++; + // } + // } + // } public async scanAddresses(): Promise { // if (!this._password) { diff --git a/apps/extension/src/background/keyring/service.ts b/apps/extension/src/background/keyring/service.ts index 3d53ffa3cf9..0e5f6a7a67f 100644 --- a/apps/extension/src/background/keyring/service.ts +++ b/apps/extension/src/background/keyring/service.ts @@ -1,7 +1,7 @@ -import { fromBase64 } from "@cosmjs/encoding"; +import { fromBase64, fromHex } from "@cosmjs/encoding"; import { PhraseSize } from "@namada/crypto"; -import { Query, Sdk, TxType } from "@namada/shared"; +import { public_key_to_bech32, Query, Sdk, TxType } from "@namada/shared"; import { IndexedDBKVStore, KVStore } from "@namada/storage"; import { AccountType, Bip44Path, DerivedAccount } from "@namada/types"; import { Result } from "@namada/utils"; @@ -107,10 +107,12 @@ export class KeyRingService { bip44Path: Bip44Path, parentId?: string ): Promise { + const publicKeyBytes = fromHex(publicKey); + const bech32PublicKey = public_key_to_bech32(publicKeyBytes); return await this._keyRing.storeLedger( alias, address, - publicKey, + bech32PublicKey, bip44Path, parentId ); diff --git a/apps/extension/src/background/ledger/ledger.ts b/apps/extension/src/background/ledger/ledger.ts index 9ea2d8d0973..299431b26e7 100644 --- a/apps/extension/src/background/ledger/ledger.ts +++ b/apps/extension/src/background/ledger/ledger.ts @@ -11,6 +11,7 @@ import { } from "@namada/ledger-namada"; import { defaultChainId, chains } from "@namada/chains"; import { makeBip44Path } from "@namada/utils"; +import { toHex } from "@cosmjs/encoding"; const namadaChain = chains[defaultChainId]; const { coinType } = namadaChain.bip44; @@ -30,7 +31,7 @@ export const DEFAULT_LEDGER_BIP44_PATH = makeBip44Path(coinType, { }); export class Ledger { - constructor(public readonly namadaApp: NamadaApp | undefined = undefined) {} + constructor(public readonly namadaApp: NamadaApp | undefined = undefined) { } /** * Returns an initialized Ledger class instance with initialized Transport @@ -85,7 +86,7 @@ export class Ledger { // Return address as bech32-encoded string address: address.toString(), // Return public key as hex-encoded string - publicKey: publicKey.toString("hex").substring(2), + publicKey: toHex(publicKey), }; } diff --git a/apps/namada-interface/src/App/AccountOverview/DerivedAccounts/DerivedAccounts.tsx b/apps/namada-interface/src/App/AccountOverview/DerivedAccounts/DerivedAccounts.tsx index da4c1ec000c..80b9bd27747 100644 --- a/apps/namada-interface/src/App/AccountOverview/DerivedAccounts/DerivedAccounts.tsx +++ b/apps/namada-interface/src/App/AccountOverview/DerivedAccounts/DerivedAccounts.tsx @@ -54,14 +54,6 @@ const assetIconByToken: Record = { light: AssetEthereumEther, dark: AssetEthereumEther, }, - ["TESTERC20"]: { - light: AssetEthereumEther, - dark: AssetEthereumEther, - }, - ["NUTTESTERC20"]: { - light: AssetEthereumEther, - dark: AssetEthereumEther, - }, ["ATOM"]: { light: AssetCosmosAtom, dark: AssetCosmosAtom, @@ -204,7 +196,8 @@ const DerivedAccounts = ({ setTotal }: Props): JSX.Element => { - {amount.toString()} {Tokens[token as TokenType].symbol} + {amount.toString()}{" "} + {Tokens[token as TokenType].symbol} ); })} diff --git a/apps/namada-interface/src/App/Token/TokenSend/TokenSend.tsx b/apps/namada-interface/src/App/Token/TokenSend/TokenSend.tsx index 0a09a12bba3..d035a768c44 100644 --- a/apps/namada-interface/src/App/Token/TokenSend/TokenSend.tsx +++ b/apps/namada-interface/src/App/Token/TokenSend/TokenSend.tsx @@ -101,7 +101,7 @@ const TokenSend = (): JSX.Element => { let defaultTab = 0; // Load the correct form if coming from URL in QR code: - if (target && target.startsWith("atest")) { + if (target && target.startsWith("tnam")) { defaultTab = 1; } @@ -112,13 +112,13 @@ const TokenSend = (): JSX.Element => { const handleTokenChange = (selectAccountFn: (accId: string) => void) => - (e: React.ChangeEvent): void => { - const { value } = e.target; - const [accountId, tokenSymbol] = value.split("|"); + (e: React.ChangeEvent): void => { + const { value } = e.target; + const [accountId, tokenSymbol] = value.split("|"); - selectAccountFn(accountId); - setToken(tokenSymbol as TokenType); - }; + selectAccountFn(accountId); + setToken(tokenSymbol as TokenType); + }; return ( @@ -153,7 +153,7 @@ const TokenSend = (): JSX.Element => { address={selectedShieldedAccountAddress} tokenType={token} defaultTarget={ - target?.startsWith("patest") ? target : undefined + target?.startsWith("znam") ? target : undefined } /> )} @@ -181,7 +181,7 @@ const TokenSend = (): JSX.Element => { address={selectedTransparentAccountAddress} tokenType={token} defaultTarget={ - target?.startsWith("atest") ? target : undefined + target?.startsWith("tnam") ? target : undefined } /> )} diff --git a/apps/namada-interface/src/App/Token/TokenSend/types.ts b/apps/namada-interface/src/App/Token/TokenSend/types.ts index 5de676b5f64..3e3826a2dba 100644 --- a/apps/namada-interface/src/App/Token/TokenSend/types.ts +++ b/apps/namada-interface/src/App/Token/TokenSend/types.ts @@ -1,4 +1,4 @@ -export const PAYMENT_ADDRESS_PREFIX = "patest1"; +export const PAYMENT_ADDRESS_PREFIX = "znam1"; export const PAYMENT_ADDRESS_LENGTH = 82; -export const ESTABLISHED_ADDRESS_PREFIX = "atest1"; -export const ESTABLISHED_ADDRESS_LENGTH = 84; +export const ESTABLISHED_ADDRESS_PREFIX = "tnam1"; +export const ESTABLISHED_ADDRESS_LENGTH = 45; diff --git a/apps/namada-interface/src/store/mocks.ts b/apps/namada-interface/src/store/mocks.ts index f62a9db6ae3..a64d23db950 100644 --- a/apps/namada-interface/src/store/mocks.ts +++ b/apps/namada-interface/src/store/mocks.ts @@ -8,30 +8,27 @@ export const mockAppState: RootState = { accounts: { derived: { "namada-masp-1.5.32ccad5356012a7": { - atest1v4ehgw36xqcyz3zrxsenzd3kxsunsvzzxymyywpkg4zrjv2pxepyyd3cgse5gwzxgsm5x3zrkf2pwp: - { - details: { - chainId: "namada-masp-1.5.32ccad5356012a7", - alias: "Namada", - address: - "atest1v4ehgw36xqcyz3zrxsenzd3kxsunsvzzxymyywpkg4zrjv2pxepyyd3cgse5gwzxgsm5x3zrkf2pwp", - isShielded: false, - type: AccountType.PrivateKey, - }, - balance: { - NAM: new BigNumber(1000), - ATOM: new BigNumber(1000), - ETH: new BigNumber(1000), - }, + tnam1q8gpzlamqksqjagt2xs3p6tnfcldy0fcd53fs4jh: { + details: { + chainId: "namada-masp-1.5.32ccad5356012a7", + alias: "Namada", + address: "tnam1q8gpzlamqksqjagt2xs3p6tnfcldy0fcd53fs4jh", + isShielded: false, + type: AccountType.PrivateKey, + }, + balance: { + NAM: new BigNumber(1000), + ATOM: new BigNumber(1000), + ETH: new BigNumber(1000), }, + }, }, "namada-test.1e670ba91369ec891fc": { "39UL18": { details: { chainId: "namada-test.1e670ba91369ec891fc", alias: "Namada", - address: - "atest1v4ehgw36xqcyz3zrxsenzd3kxsunsvzzxymyywpkg4zrjv2pxepyyd3cgse5gwzxgsm5x3zrkf2pwp", + address: "tnam1qz4sdx5jlh909j44uz46pf29ty0ztftfzc98s8dx", type: AccountType.PrivateKey, isShielded: false, }, diff --git a/packages/chains/src/chains/namada.ts b/packages/chains/src/chains/namada.ts index 8c39e28c67e..ed8fb4d771d 100644 --- a/packages/chains/src/chains/namada.ts +++ b/packages/chains/src/chains/namada.ts @@ -5,7 +5,7 @@ const DEFAULT_ALIAS = "Namada Testnet"; const DEFAULT_CHAIN_ID = "qc-testnet-5.1.025a61165acd05e"; const DEFAULT_RPC = "https://d3brk13lbhxfdb.cloudfront.net/qc-testnet-5.1.025a61165acd05e"; -const DEFAULT_BECH32_PREFIX = "atest"; +const DEFAULT_BECH32_PREFIX = "tnam"; const { REACT_APP_PROXY: isProxied, diff --git a/packages/integrations/src/Metamask.ts b/packages/integrations/src/Metamask.ts index b0ad154dd10..d7e0903cd88 100644 --- a/packages/integrations/src/Metamask.ts +++ b/packages/integrations/src/Metamask.ts @@ -8,7 +8,7 @@ import { Chain, MetamaskEvents, TokenBalance, - Tokens, + // Tokens, } from "@namada/types"; import { shortenAddress } from "@namada/utils"; import { BridgeProps, Integration } from "./types/Integration"; @@ -27,7 +27,7 @@ type MetamaskWindow = Window & class Metamask implements Integration { private _ethereum: MetaMaskInpageProvider | undefined; - constructor(public readonly chain: Chain) {} + constructor(public readonly chain: Chain) { } private init(): void { if ((window).ethereum) { @@ -121,19 +121,20 @@ class Metamask implements Integration { public async queryBalances(owner: string): Promise { const provider = new ethers.BrowserProvider(window.ethereum); const ethBalance = await provider.getBalance(owner); - const signer = await provider.getSigner(owner); + // TODO: Re-enable the following when we Erc20 tokens are fully supported: + // const signer = await provider.getSigner(owner); - const erc = new ethers.Contract( - //TODO: fix after we support add support for any kind of Erc20 token - Tokens["TESTERC20"].nativeAddress as string, - erc20Abi, - signer - ); - const testErc20Balance: bigint = await erc.balanceOf(signer.address); + // const erc = new ethers.Contract( + // //TODO: fix after we support add support for any kind of Erc20 token + // Tokens["TESTERC20"].nativeAddress as string, + // erc20Abi, + // signer + // ); + // const testErc20Balance: bigint = await erc.balanceOf(signer.address); return [ { token: "ETH", amount: String(ethBalance) || "0" }, - { token: "TESTERC20", amount: String(testErc20Balance) || "0" }, + // { token: "TESTERC20", amount: String(testErc20Balance) || "0" }, ]; } } diff --git a/packages/ledger-namada/dist/processResponses.js b/packages/ledger-namada/dist/processResponses.js index f24506f61b6..600b8b8af0c 100644 --- a/packages/ledger-namada/dist/processResponses.js +++ b/packages/ledger-namada/dist/processResponses.js @@ -19,7 +19,6 @@ exports.processGetAddrResponse = exports.getSignatureResponse = void 0; const common_1 = require("./common"); const config_1 = require("./config"); function getSignatureResponse(response) { - console.log('Processing get signature response'); // App sign response: [ pubkey(33) | raw_salt(8) | raw_signature(65) | wrapper_salt(8) | wrapper_signature(65) | // raw_indices_len(1) | wrapper_indices_len(1) | indices(wrapper_indices_len) ] let offset = 0; @@ -53,7 +52,6 @@ function getSignatureResponse(response) { } exports.getSignatureResponse = getSignatureResponse; function processGetAddrResponse(response) { - console.log('Processing get address response'); const errorCodeData = response.subarray(-2); const returnCode = errorCodeData[0] * 256 + errorCodeData[1]; const publicKey = Buffer.from(response.subarray(0, config_1.PK_LEN_PLUS_TAG)); diff --git a/packages/ledger-namada/dist/processResponses.js.map b/packages/ledger-namada/dist/processResponses.js.map index 3af7aa00f8e..96bbae6c818 100644 --- a/packages/ledger-namada/dist/processResponses.js.map +++ b/packages/ledger-namada/dist/processResponses.js.map @@ -1 +1 @@ -{"version":3,"file":"processResponses.js","sourceRoot":"","sources":["../src/processResponses.ts"],"names":[],"mappings":"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","sourcesContent":["/** ******************************************************************************\n * (c) 2018 - 2022 Zondax AG\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ******************************************************************************* */\n\nimport { errorCodeToString } from './common'\nimport { PK_LEN_PLUS_TAG, SALT_LEN, SIG_LEN_PLUS_TAG } from './config'\nimport { ISignature } from './types'\n\nexport function getSignatureResponse(response: Buffer): ISignature {\n console.log('Processing get signature response')\n\n // App sign response: [ pubkey(33) | raw_salt(8) | raw_signature(65) | wrapper_salt(8) | wrapper_signature(65) |\n // raw_indices_len(1) | wrapper_indices_len(1) | indices(wrapper_indices_len) ]\n let offset = 0;\n const pubkey = Buffer.from(response.subarray(offset, offset + PK_LEN_PLUS_TAG));\n\n offset += PK_LEN_PLUS_TAG;\n const raw_salt = Buffer.from(response.subarray(offset, offset + SALT_LEN));\n offset += SALT_LEN;\n const raw_signature = Buffer.from(response.subarray(offset, offset + SIG_LEN_PLUS_TAG));\n\n offset += SIG_LEN_PLUS_TAG;\n const wrapper_salt = Buffer.from(response.subarray(offset, offset + SALT_LEN));\n offset += SALT_LEN;\n const wrapper_signature = Buffer.from(response.subarray(offset, offset + SIG_LEN_PLUS_TAG));\n\n offset += SIG_LEN_PLUS_TAG;\n const raw_indices_len = response[offset];\n offset += 1;\n const raw_indices = Buffer.from(response.subarray(offset, offset + raw_indices_len))\n offset += raw_indices_len;\n \n const wrapper_indices_len = response[offset];\n offset += 1;\n const wrapper_indices = Buffer.from(response.subarray(offset, offset + wrapper_indices_len))\n offset += wrapper_indices_len;\n\n return {\n pubkey,\n raw_salt,\n raw_signature,\n wrapper_salt,\n wrapper_signature,\n raw_indices,\n wrapper_indices,\n }\n}\n\nexport function processGetAddrResponse(response: Buffer) {\n console.log('Processing get address response')\n\n const errorCodeData = response.subarray(-2)\n const returnCode = errorCodeData[0] * 256 + errorCodeData[1]\n\n const publicKey = Buffer.from(response.subarray(0, PK_LEN_PLUS_TAG))\n const address = Buffer.from(response.subarray(PK_LEN_PLUS_TAG, -2))\n\n return {\n publicKey,\n address,\n returnCode,\n errorMessage: errorCodeToString(returnCode),\n }\n}\n\n// Not used yet\n// function processGetShieldedAddrResponse(response: Buffer) {\n// console.log(\"Processing get address response\")\n\n// let partialResponse = response\n\n// const errorCodeData = partialResponse.slice(-2)\n// const returnCode = errorCodeData[0] * 256 + errorCodeData[1]\n\n// //get public key len (variable)\n// const raw_pkd = Buffer.from(partialResponse.slice(0, 32))\n\n// //\"advance\" buffer\n// partialResponse = partialResponse.slice(32)\n\n// // get the length of the bech32m address\n// const bech32m_len = partialResponse[0]\n\n// //\"advance\" buffer\n// partialResponse = partialResponse.slice(1)\n\n// // get the bech32m encoding of the shielded address\n// const bech32m_addr = Buffer.from(partialResponse.slice(0, bech32m_len))\n\n// return {\n// raw_pkd,\n// bech32m_len,\n// bech32m_addr,\n// returnCode,\n// errorMessage: errorCodeToString(returnCode),\n// }\n// }\n\n// function processIncomingViewingKeyResponse(response: Buffer) {\n// console.log(\"Processing get IVK response\")\n\n// const partialResponse = response\n\n// const errorCodeData = partialResponse.slice(-2)\n// const returnCode = errorCodeData[0] * 256 + errorCodeData[1]\n\n// //get public key len (variable)\n// const raw_ivk = Buffer.from(partialResponse.slice(0, 32))\n\n// return {\n// raw_ivk,\n// returnCode,\n// errorMessage: errorCodeToString(returnCode),\n// }\n// }\n\n// function processNullifierResponse(response: Buffer) {\n// console.log(\"Processing get nullifier response\")\n\n// const partialResponse = response\n\n// const errorCodeData = partialResponse.slice(-2)\n// const returnCode = errorCodeData[0] * 256 + errorCodeData[1]\n\n// const raw_nf = Buffer.from(partialResponse.slice(0, 32))\n\n// return {\n// raw_nf,\n// returnCode,\n// errorMessage: errorCodeToString(returnCode),\n// }\n// }\n\n// function processOutgoingViewingKeyResponse(response: Buffer) {\n// console.log(\"Processing get OVK response\")\n\n// const partialResponse = response\n\n// const errorCodeData = partialResponse.slice(-2)\n// const returnCode = errorCodeData[0] * 256 + errorCodeData[1]\n\n// //get public key len (variable)\n// const raw_ovk = Buffer.from(partialResponse.slice(0, 32))\n\n// return {\n// raw_ovk,\n// returnCode,\n// errorMessage: errorCodeToString(returnCode),\n// }\n// }\n"]} \ No newline at end of file +{"version":3,"file":"processResponses.js","sourceRoot":"","sources":["../src/processResponses.ts"],"names":[],"mappings":"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","sourcesContent":["/** ******************************************************************************\n * (c) 2018 - 2022 Zondax AG\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ******************************************************************************* */\n\nimport { errorCodeToString } from './common'\nimport { PK_LEN_PLUS_TAG, SALT_LEN, SIG_LEN_PLUS_TAG } from './config'\nimport { ISignature } from './types'\n\nexport function getSignatureResponse(response: Buffer): ISignature {\n // App sign response: [ pubkey(33) | raw_salt(8) | raw_signature(65) | wrapper_salt(8) | wrapper_signature(65) |\n // raw_indices_len(1) | wrapper_indices_len(1) | indices(wrapper_indices_len) ]\n\n let offset = 0;\n const pubkey = Buffer.from(response.subarray(offset, offset + PK_LEN_PLUS_TAG));\n\n offset += PK_LEN_PLUS_TAG;\n const raw_salt = Buffer.from(response.subarray(offset, offset + SALT_LEN));\n offset += SALT_LEN;\n const raw_signature = Buffer.from(response.subarray(offset, offset + SIG_LEN_PLUS_TAG));\n\n offset += SIG_LEN_PLUS_TAG;\n const wrapper_salt = Buffer.from(response.subarray(offset, offset + SALT_LEN));\n offset += SALT_LEN;\n const wrapper_signature = Buffer.from(response.subarray(offset, offset + SIG_LEN_PLUS_TAG));\n\n offset += SIG_LEN_PLUS_TAG;\n const raw_indices_len = response[offset];\n offset += 1;\n const raw_indices = Buffer.from(response.subarray(offset, offset + raw_indices_len))\n offset += raw_indices_len;\n\n const wrapper_indices_len = response[offset];\n offset += 1;\n const wrapper_indices = Buffer.from(response.subarray(offset, offset + wrapper_indices_len))\n offset += wrapper_indices_len;\n\n return {\n pubkey,\n raw_salt,\n raw_signature,\n wrapper_salt,\n wrapper_signature,\n raw_indices,\n wrapper_indices,\n }\n}\n\nexport function processGetAddrResponse(response: Buffer) {\n const errorCodeData = response.subarray(-2)\n const returnCode = errorCodeData[0] * 256 + errorCodeData[1]\n\n const publicKey = Buffer.from(response.subarray(0, PK_LEN_PLUS_TAG))\n const address = Buffer.from(response.subarray(PK_LEN_PLUS_TAG, -2))\n\n return {\n publicKey,\n address,\n returnCode,\n errorMessage: errorCodeToString(returnCode),\n }\n}\n\n// Not used yet\n// function processGetShieldedAddrResponse(response: Buffer) {\n// console.log(\"Processing get address response\")\n\n// let partialResponse = response\n\n// const errorCodeData = partialResponse.slice(-2)\n// const returnCode = errorCodeData[0] * 256 + errorCodeData[1]\n\n// //get public key len (variable)\n// const raw_pkd = Buffer.from(partialResponse.slice(0, 32))\n\n// //\"advance\" buffer\n// partialResponse = partialResponse.slice(32)\n\n// // get the length of the bech32m address\n// const bech32m_len = partialResponse[0]\n\n// //\"advance\" buffer\n// partialResponse = partialResponse.slice(1)\n\n// // get the bech32m encoding of the shielded address\n// const bech32m_addr = Buffer.from(partialResponse.slice(0, bech32m_len))\n\n// return {\n// raw_pkd,\n// bech32m_len,\n// bech32m_addr,\n// returnCode,\n// errorMessage: errorCodeToString(returnCode),\n// }\n// }\n\n// function processIncomingViewingKeyResponse(response: Buffer) {\n// console.log(\"Processing get IVK response\")\n\n// const partialResponse = response\n\n// const errorCodeData = partialResponse.slice(-2)\n// const returnCode = errorCodeData[0] * 256 + errorCodeData[1]\n\n// //get public key len (variable)\n// const raw_ivk = Buffer.from(partialResponse.slice(0, 32))\n\n// return {\n// raw_ivk,\n// returnCode,\n// errorMessage: errorCodeToString(returnCode),\n// }\n// }\n\n// function processNullifierResponse(response: Buffer) {\n// console.log(\"Processing get nullifier response\")\n\n// const partialResponse = response\n\n// const errorCodeData = partialResponse.slice(-2)\n// const returnCode = errorCodeData[0] * 256 + errorCodeData[1]\n\n// const raw_nf = Buffer.from(partialResponse.slice(0, 32))\n\n// return {\n// raw_nf,\n// returnCode,\n// errorMessage: errorCodeToString(returnCode),\n// }\n// }\n\n// function processOutgoingViewingKeyResponse(response: Buffer) {\n// console.log(\"Processing get OVK response\")\n\n// const partialResponse = response\n\n// const errorCodeData = partialResponse.slice(-2)\n// const returnCode = errorCodeData[0] * 256 + errorCodeData[1]\n\n// //get public key len (variable)\n// const raw_ovk = Buffer.from(partialResponse.slice(0, 32))\n\n// return {\n// raw_ovk,\n// returnCode,\n// errorMessage: errorCodeToString(returnCode),\n// }\n// }\n"]} \ No newline at end of file diff --git a/packages/shared/lib/Cargo.lock b/packages/shared/lib/Cargo.lock index 12fb4f4c7f4..1e960a5e696 100644 --- a/packages/shared/lib/Cargo.lock +++ b/packages/shared/lib/Cargo.lock @@ -35,21 +35,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac1f845298e95f983ff1944b728ae08b8cebab80d684f0a832ed0fc74dfa27e2" dependencies = [ "cfg-if", - "cipher 0.4.4", + "cipher", "cpufeatures", ] -[[package]] -name = "ahash" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" -dependencies = [ - "getrandom 0.2.9", - "once_cell", - "version_check", -] - [[package]] name = "aho-corasick" version = "1.0.5" @@ -99,18 +88,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "ark-ed-on-bls12-381" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43b7ada17db3854f5994e74e60b18e10e818594935ee7e1d329800c117b32970" -dependencies = [ - "ark-bls12-381", - "ark-ec", - "ark-ff", - "ark-std", -] - [[package]] name = "ark-ff" version = "0.3.0" @@ -151,41 +128,16 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "ark-poly" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b0f78f47537c2f15706db7e98fe64cc1711dbf9def81218194e17239e53e5aa" -dependencies = [ - "ark-ff", - "ark-serialize", - "ark-std", - "derivative", - "hashbrown 0.11.2", -] - [[package]] name = "ark-serialize" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1d6c2b318ee6e10f8c2853e73a83adc0ccb88995aa978d8a3408d492ab2ee671" dependencies = [ - "ark-serialize-derive", "ark-std", "digest 0.9.0", ] -[[package]] -name = "ark-serialize-derive" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8dd4e5f0bf8285d5ed538d27fab7411f3e297908fd93c62195de8bee3f199e82" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "ark-std" version = "0.3.0" @@ -225,7 +177,7 @@ checksum = "b9ccdd8f2a161be9bd5c023df56f1b2a0bd1d83872ae53b71a84a12c9bf6e842" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.39", ] [[package]] @@ -324,15 +276,6 @@ dependencies = [ "serde", ] -[[package]] -name = "bincode" -version = "1.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" -dependencies = [ - "serde", -] - [[package]] name = "bip0039" version = "0.10.1" @@ -380,15 +323,6 @@ dependencies = [ "wyz", ] -[[package]] -name = "blake2" -version = "0.10.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46502ad458c9a52b69d4d4d32775c788b7a1b85e8bc9d482d92250fc0e3f8efe" -dependencies = [ - "digest 0.10.7", -] - [[package]] name = "blake2b_simd" version = "1.0.1" @@ -463,62 +397,16 @@ dependencies = [ "subtle 2.4.1", ] -[[package]] -name = "borsh" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15bf3650200d8bffa99015595e10f1fbd17de07abbc25bb067da79e769939bfa" -dependencies = [ - "borsh-derive 0.9.3", - "hashbrown 0.11.2", -] - -[[package]] -name = "borsh" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4114279215a005bc675e386011e594e1d9b800918cea18fcadadcce864a2046b" -dependencies = [ - "borsh-derive 0.10.3", - "hashbrown 0.12.3", -] - [[package]] name = "borsh" version = "1.0.0-alpha.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41898277107b0d3f027593697912977397eba6ac39a55bdd2eb02c1d5d5013b5" dependencies = [ - "borsh-derive 1.0.0-alpha.4", + "borsh-derive", "cfg_aliases", ] -[[package]] -name = "borsh-derive" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6441c552f230375d18e3cc377677914d2ca2b0d36e52129fe15450a2dce46775" -dependencies = [ - "borsh-derive-internal 0.9.3", - "borsh-schema-derive-internal 0.9.3", - "proc-macro-crate 0.1.5", - "proc-macro2", - "syn 1.0.109", -] - -[[package]] -name = "borsh-derive" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0754613691538d51f329cce9af41d7b7ca150bc973056f1156611489475f54f7" -dependencies = [ - "borsh-derive-internal 0.10.3", - "borsh-schema-derive-internal 0.10.3", - "proc-macro-crate 0.1.5", - "proc-macro2", - "syn 1.0.109", -] - [[package]] name = "borsh-derive" version = "1.0.0-alpha.4" @@ -526,63 +414,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "413cb435569fe499e89235f758304e0e7198016baa351d8f5827ea0f40526ce0" dependencies = [ "once_cell", - "proc-macro-crate 1.3.1", + "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.39", "syn_derive", ] -[[package]] -name = "borsh-derive-internal" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5449c28a7b352f2d1e592a8a28bf139bc71afb0764a14f3c02500935d8c44065" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "borsh-derive-internal" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afb438156919598d2c7bad7e1c0adf3d26ed3840dbc010db1a882a65583ca2fb" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "borsh-ext" version = "1.0.0-alpha.4" source = "git+https://github.com/heliaxdev/borsh-ext?tag=v1.0.0-alpha.4#6bebf357002f96574ac37a28f547b6c88e91b799" dependencies = [ - "borsh 1.0.0-alpha.4", -] - -[[package]] -name = "borsh-schema-derive-internal" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdbd5696d8bfa21d53d9fe39a714a18538bad11492a42d066dbbc395fb1951c0" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "borsh-schema-derive-internal" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "634205cc43f74a1b9046ef87c4540ebda95696ec0f315024860cad7c5b0f5ccd" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", + "borsh", ] [[package]] @@ -687,7 +531,7 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26b52a9543ae338f279b96b0b9fed9c8093744685043739079ce85cd58f289a6" dependencies = [ - "cipher 0.4.4", + "cipher", ] [[package]] @@ -711,17 +555,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" -[[package]] -name = "chacha20" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c80e5460aa66fe3b91d40bcbdab953a597b60053e34d684ac6903f863b680a6" -dependencies = [ - "cfg-if", - "cipher 0.3.0", - "cpufeatures", -] - [[package]] name = "chacha20" version = "0.9.1" @@ -729,7 +562,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3613f74bd2eac03dad61bd53dbe620703d4371614fe0bc3b9f04dd36fe4e818" dependencies = [ "cfg-if", - "cipher 0.4.4", + "cipher", "cpufeatures", ] @@ -740,8 +573,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "10cd79432192d1c0f4e1a0fef9527696cc039165d729fb41b3f4f4f354c2dc35" dependencies = [ "aead", - "chacha20 0.9.1", - "cipher 0.4.4", + "chacha20", + "cipher", "poly1305", "zeroize", ] @@ -761,15 +594,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "cipher" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ee52072ec15386f770805afd189a01c8841be8696bed250fa2f13c4c0d6dfb7" -dependencies = [ - "generic-array 0.14.7", -] - [[package]] name = "cipher" version = "0.4.4" @@ -1002,20 +826,7 @@ version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0369ee1ad671834580515889b80f2ea915f23b8be8d0daa4bbaf2ac5c7590835" dependencies = [ - "cipher 0.4.4", -] - -[[package]] -name = "curve25519-dalek" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b9fdf9972b2bd6af2d913799d9ebc165ea4d2e65878e329d9c6b372c4491b61" -dependencies = [ - "byteorder", - "digest 0.9.0", - "rand_core 0.5.1", - "subtle 2.4.1", - "zeroize", + "cipher", ] [[package]] @@ -1031,6 +842,41 @@ dependencies = [ "zeroize", ] +[[package]] +name = "darling" +version = "0.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0209d94da627ab5605dcccf08bb18afa5009cfbef48d8a8b7d7bdbc79be25c5e" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "177e3443818124b357d8e76f53be906d60937f0d3a90773a664fa63fa253e621" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn 2.0.39", +] + +[[package]] +name = "darling_macro" +version = "0.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" +dependencies = [ + "darling_core", + "quote", + "syn 2.0.39", +] + [[package]] name = "data-encoding" version = "2.4.0" @@ -1160,7 +1006,7 @@ checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.39", ] [[package]] @@ -1169,12 +1015,6 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "56ce8c6da7551ec6c462cbaf3bfbc75131ebbfa1c944aeaa9dab51ca1c5f0c3b" -[[package]] -name = "dyn-clone" -version = "1.0.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbfc4744c1b8f2a09adc0e55242f60b1af195d88596bd8700be74418c056c555" - [[package]] name = "ecdsa" version = "0.16.8" @@ -1186,18 +1026,18 @@ dependencies = [ "elliptic-curve", "rfc6979", "serdect", - "signature 2.1.0", + "signature", "spki", ] [[package]] name = "ed25519" -version = "1.5.3" +version = "2.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91cff35c70bba8a626e3185d8cd48cc11b5437e1a5bcd15b9b5fa3c64b6dfee7" +checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" dependencies = [ - "serde", - "signature 1.6.4", + "pkcs8", + "signature", ] [[package]] @@ -1216,17 +1056,14 @@ dependencies = [ ] [[package]] -name = "ed25519-dalek" -version = "1.0.1" +name = "ed25519-consensus" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c762bae6dcaf24c4c84667b8579785430908723d5c889f469d76a41d59cc7a9d" +checksum = "3c8465edc8ee7436ffea81d21a019b16676ee3db267aa8d5a8d729581ecf998b" dependencies = [ - "curve25519-dalek", - "ed25519", - "merlin", - "rand 0.7.3", - "serde", - "serde_bytes", + "curve25519-dalek-ng", + "hex", + "rand_core 0.6.4", "sha2 0.9.9", "zeroize", ] @@ -1299,15 +1136,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" -[[package]] -name = "erased-serde" -version = "0.3.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6984864d65d092d9e9ada107007a846a09f75d2e24046bcce9a38d14aa52052" -dependencies = [ - "serde", -] - [[package]] name = "errno" version = "0.3.3" @@ -1498,7 +1326,7 @@ dependencies = [ "reqwest", "serde", "serde_json", - "syn 2.0.16", + "syn 2.0.39", "toml 0.7.6", "walkdir", ] @@ -1516,7 +1344,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.16", + "syn 2.0.39", ] [[package]] @@ -1534,7 +1362,7 @@ dependencies = [ "generic-array 0.14.7", "hex", "k256", - "num_enum", + "num_enum 0.6.1", "once_cell", "open-fastrlp", "rand 0.8.5", @@ -1542,7 +1370,7 @@ dependencies = [ "serde", "serde_json", "strum", - "syn 2.0.16", + "syn 2.0.39", "tempfile", "thiserror", "tiny-keccak", @@ -1702,56 +1530,6 @@ dependencies = [ "instant", ] -[[package]] -name = "ferveo" -version = "0.1.1" -source = "git+https://github.com/anoma/ferveo?rev=e5abd0acc938da90140351a65a26472eb495ce4d#e5abd0acc938da90140351a65a26472eb495ce4d" -dependencies = [ - "anyhow", - "ark-bls12-381", - "ark-ec", - "ark-ed-on-bls12-381", - "ark-ff", - "ark-poly", - "ark-serialize", - "ark-std", - "bincode", - "blake2", - "blake2b_simd", - "borsh 0.9.3", - "digest 0.10.7", - "ed25519-dalek", - "either", - "ferveo-common", - "group-threshold-cryptography", - "hex", - "itertools 0.10.5", - "measure_time", - "miracl_core", - "num 0.4.1", - "rand 0.7.3", - "rand 0.8.5", - "serde", - "serde_bytes", - "serde_json", - "subproductdomain", - "subtle 2.4.1", - "zeroize", -] - -[[package]] -name = "ferveo-common" -version = "0.1.0" -source = "git+https://github.com/anoma/ferveo?rev=e5abd0acc938da90140351a65a26472eb495ce4d#e5abd0acc938da90140351a65a26472eb495ce4d" -dependencies = [ - "anyhow", - "ark-ec", - "ark-serialize", - "ark-std", - "serde", - "serde_bytes", -] - [[package]] name = "ff" version = "0.13.0" @@ -1823,7 +1601,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26c4b37de5ae15812a764c958297cfc50f5c010438f60c6ce75d11b802abd404" dependencies = [ "cbc", - "cipher 0.4.4", + "cipher", "libm", "num-bigint 0.4.3", "num-integer", @@ -1912,7 +1690,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.39", ] [[package]] @@ -2053,30 +1831,6 @@ dependencies = [ "subtle 2.4.1", ] -[[package]] -name = "group-threshold-cryptography" -version = "0.1.0" -source = "git+https://github.com/anoma/ferveo?rev=e5abd0acc938da90140351a65a26472eb495ce4d#e5abd0acc938da90140351a65a26472eb495ce4d" -dependencies = [ - "anyhow", - "ark-bls12-381", - "ark-ec", - "ark-ff", - "ark-poly", - "ark-serialize", - "ark-std", - "blake2b_simd", - "chacha20 0.8.2", - "hex", - "itertools 0.10.5", - "miracl_core", - "rand 0.8.5", - "rand_core 0.6.4", - "rayon", - "subproductdomain", - "thiserror", -] - [[package]] name = "h2" version = "0.3.21" @@ -2096,23 +1850,11 @@ dependencies = [ "tracing", ] -[[package]] -name = "hashbrown" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" -dependencies = [ - "ahash", -] - [[package]] name = "hashbrown" version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" -dependencies = [ - "ahash", -] [[package]] name = "hashbrown" @@ -2299,23 +2041,22 @@ dependencies = [ [[package]] name = "ibc" -version = "0.41.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs.git?rev=206cb5fa74a7ca38038b937d202ae39fbbd63c19#206cb5fa74a7ca38038b937d202ae39fbbd63c19" +version = "0.47.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "184eb22140cb4143bbcf7ddc8fdfeb9cc058ef73a6066f8ea78162e69d3565d1" dependencies = [ "bytes", "derive_more", "displaydoc", - "dyn-clone", - "erased-serde", + "ibc-derive", "ibc-proto", "ics23", "num-traits", "primitive-types", - "prost 0.11.9", - "safe-regex", + "prost 0.12.1", "serde", + "serde-json-wasm", "serde_derive", - "serde_json", "sha2 0.10.7", "subtle-encoding", "tendermint", @@ -2326,18 +2067,29 @@ dependencies = [ "uint", ] +[[package]] +name = "ibc-derive" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92f1528535e9ca495badb76c143bdd4763c1c9d987f59d1f8b47963ba0c11674" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn 2.0.39", +] + [[package]] name = "ibc-proto" -version = "0.30.0" -source = "git+https://github.com/heliaxdev/ibc-proto-rs.git?rev=31892ee743b2af017d5629b2af419ee20b6100c7#31892ee743b2af017d5629b2af419ee20b6100c7" +version = "0.37.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63042806bb2f662ca1c68026231900cfe13361136ddfd0dd09bcb315056a22b8" dependencies = [ "base64 0.21.3", - "borsh 0.10.3", "bytes", "flex-error", - "parity-scale-codec", - "prost 0.11.9", - "scale-info", + "ics23", + "prost 0.12.1", "serde", "subtle-encoding", "tendermint-proto", @@ -2345,19 +2097,27 @@ dependencies = [ [[package]] name = "ics23" -version = "0.9.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca44b684ce1859cff746ff46f5765ab72e12e3c06f76a8356db8f9a2ecf43f17" +checksum = "661e2d6f79952a65bc92b1c81f639ebd37228dae6ff412a5aba7d474bdc4b957" dependencies = [ "anyhow", "bytes", "hex", - "prost 0.11.9", + "informalsystems-pbjson", + "prost 0.12.1", "ripemd", + "serde", "sha2 0.10.7", "sha3", ] +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + [[package]] name = "idna" version = "0.4.0" @@ -2437,7 +2197,7 @@ name = "index-set" version = "0.8.0" source = "git+https://github.com/heliaxdev/index-set?tag=v0.8.0#0c218cc300c1bb7a1acf34f21b6e9d489df5fda8" dependencies = [ - "borsh 1.0.0-alpha.4", + "borsh", "serde", ] @@ -2461,6 +2221,16 @@ dependencies = [ "hashbrown 0.14.0", ] +[[package]] +name = "informalsystems-pbjson" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4eecd90f87bea412eac91c6ef94f6b1e390128290898cbe14f2b926787ae1fb" +dependencies = [ + "base64 0.13.1", + "serde", +] + [[package]] name = "inout" version = "0.1.3" @@ -2477,9 +2247,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" dependencies = [ "cfg-if", - "js-sys", - "wasm-bindgen", - "web-sys", ] [[package]] @@ -2588,7 +2355,7 @@ dependencies = [ "once_cell", "serdect", "sha2 0.10.7", - "signature 2.1.0", + "signature", ] [[package]] @@ -2692,10 +2459,10 @@ name = "masp_note_encryption" version = "0.2.0" source = "git+https://github.com/anoma/masp?rev=77e009626f3f52fe83c81ec6ee38fc2547d38da3#77e009626f3f52fe83c81ec6ee38fc2547d38da3" dependencies = [ - "borsh 1.0.0-alpha.4", - "chacha20 0.9.1", + "borsh", + "chacha20", "chacha20poly1305", - "cipher 0.4.4", + "cipher", "rand_core 0.6.4", "subtle 2.4.1", ] @@ -2711,7 +2478,7 @@ dependencies = [ "blake2b_simd", "blake2s_simd", "bls12_381", - "borsh 1.0.0-alpha.4", + "borsh", "byteorder", "ff", "fpe", @@ -2761,16 +2528,6 @@ dependencies = [ "digest 0.10.7", ] -[[package]] -name = "measure_time" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56220900f1a0923789ecd6bf25fbae8af3b2f1ff3e9e297fc9b6b8674dd4d852" -dependencies = [ - "instant", - "log", -] - [[package]] name = "memchr" version = "2.6.3" @@ -2798,18 +2555,6 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "93c0d11ac30a033511ae414355d80f70d9f29a44a49140face477117a1ee90db" -[[package]] -name = "merlin" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e261cf0f8b3c42ded9f7d2bb59dea03aa52bc8a1cbc7482f9fc3fd1229d3b42" -dependencies = [ - "byteorder", - "keccak", - "rand_core 0.5.1", - "zeroize", -] - [[package]] name = "mime" version = "0.3.17" @@ -2849,12 +2594,6 @@ dependencies = [ "windows-sys", ] -[[package]] -name = "miracl_core" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94c7128ba23c81f6471141b90f17654f89ef44a56e14b8a4dd0fddfccd655277" - [[package]] name = "multimap" version = "0.8.3" @@ -2863,12 +2602,12 @@ checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a" [[package]] name = "namada" -version = "0.25.0" -source = "git+https://github.com/anoma/namada#8dcfddc2f1fcd4d8c1ae88f3eb1bc1815f90af3d" +version = "0.26.0" +source = "git+https://github.com/anoma/namada#e89a5a9214d40d367ee000699c98748544aa3d00" dependencies = [ "async-trait", "bimap", - "borsh 1.0.0-alpha.4", + "borsh", "borsh-ext", "circular-queue", "clru", @@ -2891,7 +2630,7 @@ dependencies = [ "owo-colors", "parse_duration", "paste", - "prost 0.11.9", + "prost 0.12.1", "rand 0.8.5", "rand_core 0.6.4", "ripemd", @@ -2913,26 +2652,23 @@ dependencies = [ [[package]] name = "namada_core" -version = "0.25.0" -source = "git+https://github.com/anoma/namada#8dcfddc2f1fcd4d8c1ae88f3eb1bc1815f90af3d" +version = "0.26.0" +source = "git+https://github.com/anoma/namada#e89a5a9214d40d367ee000699c98748544aa3d00" dependencies = [ "ark-bls12-381", - "ark-ec", "ark-serialize", "bech32 0.8.1", - "borsh 1.0.0-alpha.4", + "borsh", "borsh-ext", "chrono", "data-encoding", "derivative", - "ed25519-consensus", + "ed25519-consensus 1.2.1", "ethabi", "ethbridge-structs", "eyre", - "ferveo", - "ferveo-common", - "group-threshold-cryptography", "ibc", + "ibc-derive", "ibc-proto", "ics23", "impl-num-traits", @@ -2945,9 +2681,10 @@ dependencies = [ "num-rational 0.4.1", "num-traits", "num256", + "num_enum 0.7.1", "primitive-types", - "prost 0.11.9", - "prost-types 0.11.9", + "prost 0.12.1", + "prost-types 0.12.1", "rand 0.8.5", "rand_core 0.6.4", "serde", @@ -2966,10 +2703,10 @@ dependencies = [ [[package]] name = "namada_ethereum_bridge" -version = "0.25.0" -source = "git+https://github.com/anoma/namada#8dcfddc2f1fcd4d8c1ae88f3eb1bc1815f90af3d" +version = "0.26.0" +source = "git+https://github.com/anoma/namada#e89a5a9214d40d367ee000699c98748544aa3d00" dependencies = [ - "borsh 1.0.0-alpha.4", + "borsh", "borsh-ext", "ethers", "eyre", @@ -2988,8 +2725,8 @@ dependencies = [ [[package]] name = "namada_macros" -version = "0.25.0" -source = "git+https://github.com/anoma/namada#8dcfddc2f1fcd4d8c1ae88f3eb1bc1815f90af3d" +version = "0.26.0" +source = "git+https://github.com/anoma/namada#e89a5a9214d40d367ee000699c98748544aa3d00" dependencies = [ "proc-macro2", "quote", @@ -2998,10 +2735,10 @@ dependencies = [ [[package]] name = "namada_proof_of_stake" -version = "0.25.0" -source = "git+https://github.com/anoma/namada#8dcfddc2f1fcd4d8c1ae88f3eb1bc1815f90af3d" +version = "0.26.0" +source = "git+https://github.com/anoma/namada#e89a5a9214d40d367ee000699c98748544aa3d00" dependencies = [ - "borsh 1.0.0-alpha.4", + "borsh", "data-encoding", "derivative", "namada_core", @@ -3012,12 +2749,12 @@ dependencies = [ [[package]] name = "namada_sdk" -version = "0.25.0" -source = "git+https://github.com/anoma/namada#8dcfddc2f1fcd4d8c1ae88f3eb1bc1815f90af3d" +version = "0.26.0" +source = "git+https://github.com/anoma/namada#e89a5a9214d40d367ee000699c98748544aa3d00" dependencies = [ "async-trait", "bimap", - "borsh 1.0.0-alpha.4", + "borsh", "borsh-ext", "circular-queue", "data-encoding", @@ -3036,7 +2773,7 @@ dependencies = [ "owo-colors", "parse_duration", "paste", - "prost 0.11.9", + "prost 0.12.1", "rand 0.8.5", "rand_core 0.6.4", "ripemd", @@ -3231,7 +2968,16 @@ version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a015b430d3c108a207fd776d2e2196aaf8b1cf8cf93253e3a097ff3085076a1" dependencies = [ - "num_enum_derive", + "num_enum_derive 0.6.1", +] + +[[package]] +name = "num_enum" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "683751d591e6d81200c39fb0d1032608b77724f34114db54f571ff1317b337c0" +dependencies = [ + "num_enum_derive 0.7.1", ] [[package]] @@ -3240,10 +2986,22 @@ version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96667db765a921f7b295ffee8b60472b686a51d4f21c2ee4ffdb94c7013b65a6" dependencies = [ - "proc-macro-crate 1.3.1", + "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.39", +] + +[[package]] +name = "num_enum_derive" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c11e44798ad209ccdd91fc192f0526a369a01234f7373e1b141c96d7cee4f0e" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 2.0.39", ] [[package]] @@ -3336,7 +3094,7 @@ version = "3.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "86b26a931f824dd4eca30b3e43bb4f31cd5f0d3a403c5f5ff27106b805bfde7b" dependencies = [ - "proc-macro-crate 1.3.1", + "proc-macro-crate", "proc-macro2", "quote", "syn 1.0.109", @@ -3558,7 +3316,7 @@ dependencies = [ "phf_shared 0.11.2", "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.39", ] [[package]] @@ -3596,7 +3354,7 @@ checksum = "39407670928234ebc5e6e580247dd567ad73a3578460c5990f9503df207e8f07" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.39", ] [[package]] @@ -3667,7 +3425,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9825a04601d60621feed79c4e6b56d65db77cdca55cef43b46b0de1096d1c282" dependencies = [ "proc-macro2", - "syn 2.0.16", + "syn 2.0.39", ] [[package]] @@ -3684,15 +3442,6 @@ dependencies = [ "uint", ] -[[package]] -name = "proc-macro-crate" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d6ea3c4595b96363c13943497db34af4460fb474a95c43f4446ad341b8c9785" -dependencies = [ - "toml 0.5.11", -] - [[package]] name = "proc-macro-crate" version = "1.3.1" @@ -3729,9 +3478,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.57" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4ec6d5fe0b140acb27c9a0444118cf55bfbb4e0b259739429abb4521dd67c16" +checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" dependencies = [ "unicode-ident", ] @@ -3756,6 +3505,16 @@ dependencies = [ "prost-derive 0.11.9", ] +[[package]] +name = "prost" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4fdd22f3b9c31b53c060df4a0613a1c7f062d4115a2b984dd15b1858f7e340d" +dependencies = [ + "bytes", + "prost-derive 0.12.1", +] + [[package]] name = "prost-build" version = "0.11.9" @@ -3804,6 +3563,19 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "prost-derive" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "265baba7fabd416cf5078179f7d2cbeca4ce7a9041111900675ea7c4cb8a4c32" +dependencies = [ + "anyhow", + "itertools 0.11.0", + "proc-macro2", + "quote", + "syn 2.0.39", +] + [[package]] name = "prost-types" version = "0.9.0" @@ -3823,11 +3595,20 @@ dependencies = [ "prost 0.11.9", ] +[[package]] +name = "prost-types" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e081b29f63d83a4bc75cfc9f3fe424f9156cf92d8a4f0c9407cce9a1b67327cf" +dependencies = [ + "prost 0.12.1", +] + [[package]] name = "quote" -version = "1.0.27" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f4f29d145265ec1c483c7c654450edde0bfe043d3938d6972630663356d9500" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" dependencies = [ "proc-macro2", ] @@ -4212,60 +3993,13 @@ version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" -[[package]] -name = "safe-proc-macro2" -version = "1.0.36" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "814c536dcd27acf03296c618dab7ad62d28e70abd7ba41d3f34a2ce707a2c666" -dependencies = [ - "unicode-xid", -] - -[[package]] -name = "safe-quote" -version = "1.0.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77e530f7831f3feafcd5f1aae406ac205dd998436b4007c8e80f03eca78a88f7" -dependencies = [ - "safe-proc-macro2", -] - -[[package]] -name = "safe-regex" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a15289bf322e0673d52756a18194167f2378ec1a15fe884af6e2d2cb934822b0" -dependencies = [ - "safe-regex-macro", -] - -[[package]] -name = "safe-regex-compiler" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fba76fae590a2aa665279deb1f57b5098cbace01a0c5e60e262fcf55f7c51542" -dependencies = [ - "safe-proc-macro2", - "safe-quote", -] - -[[package]] -name = "safe-regex-macro" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96c2e96b5c03f158d1b16ba79af515137795f4ad4e8de3f790518aae91f1d127" -dependencies = [ - "safe-proc-macro2", - "safe-regex-compiler", -] - [[package]] name = "salsa20" version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97a22f5af31f73a954c10289c93e8a50cc23d971e80ee446f1f6f7137a088213" dependencies = [ - "cipher 0.4.4", + "cipher", ] [[package]] @@ -4295,7 +4029,7 @@ version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "912e55f6d20e0e80d63733872b40e1227c0bce1e1ab81ba67d696339bfd7fd29" dependencies = [ - "proc-macro-crate 1.3.1", + "proc-macro-crate", "proc-macro2", "quote", "syn 1.0.109", @@ -4391,13 +4125,22 @@ checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" [[package]] name = "serde" -version = "1.0.163" +version = "1.0.192" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2113ab51b87a539ae008b5c6c02dc020ffa39afd2d83cffcb3f4eb2722cebec2" +checksum = "bca2a08484b285dcb282d0f67b26cadc0df8b19f8c12502c13d966bf9482f001" dependencies = [ "serde_derive", ] +[[package]] +name = "serde-json-wasm" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83c37d03f3b0f6b5f77c11af1e7c772de1c9af83e50bef7bb6069601900ba67b" +dependencies = [ + "serde", +] + [[package]] name = "serde_bytes" version = "0.11.10" @@ -4409,13 +4152,13 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.163" +version = "1.0.192" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c805777e3930c8883389c602315a24224bcc738b63905ef87cd1420353ea93e" +checksum = "d6c7207fbec9faa48073f3e3074cbe553af6ea512d7c21ba46e434e70ea9fbc1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.39", ] [[package]] @@ -4437,7 +4180,7 @@ checksum = "6f0a21fba416426ac927b1691996e82079f8b6156e920c85345f135b2e9ba2de" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.39", ] [[package]] @@ -4533,7 +4276,7 @@ name = "shared" version = "0.1.0" dependencies = [ "async-trait", - "borsh 1.0.0-alpha.4", + "borsh", "borsh-ext", "chrono", "console_error_panic_hook", @@ -4543,6 +4286,7 @@ dependencies = [ "masp_primitives", "masp_proofs", "namada", + "proc-macro2", "prost 0.9.0", "prost-types 0.9.0", "rand 0.8.5", @@ -4566,12 +4310,6 @@ dependencies = [ "libc", ] -[[package]] -name = "signature" -version = "1.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" - [[package]] name = "signature" version = "2.1.0" @@ -4639,9 +4377,9 @@ dependencies = [ [[package]] name = "sparse-merkle-tree" version = "0.3.1-pre" -source = "git+https://github.com/heliaxdev/sparse-merkle-tree?rev=df7ec062e7c40d5e76b136064e9aaf8bd2490750#df7ec062e7c40d5e76b136064e9aaf8bd2490750" +source = "git+https://github.com/heliaxdev/sparse-merkle-tree?rev=aed81070ce2c83a41e1c6bada757347f33ef8eb6#aed81070ce2c83a41e1c6bada757347f33ef8eb6" dependencies = [ - "borsh 1.0.0-alpha.4", + "borsh", "cfg-if", "ics23", "sha2 0.9.9", @@ -4682,6 +4420,12 @@ dependencies = [ "precomputed-hash", ] +[[package]] +name = "strsim" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" + [[package]] name = "strum" version = "0.25.0" @@ -4701,20 +4445,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.16", -] - -[[package]] -name = "subproductdomain" -version = "0.1.0" -source = "git+https://github.com/anoma/ferveo?rev=e5abd0acc938da90140351a65a26472eb495ce4d#e5abd0acc938da90140351a65a26472eb495ce4d" -dependencies = [ - "anyhow", - "ark-ec", - "ark-ff", - "ark-poly", - "ark-serialize", - "ark-std", + "syn 2.0.39", ] [[package]] @@ -4777,9 +4508,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.16" +version = "2.0.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6f671d4b5ffdb8eadec19c0ae67fe2639df8684bd7bc4b83d986b8db549cf01" +checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" dependencies = [ "proc-macro2", "quote", @@ -4795,7 +4526,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.39", ] [[package]] @@ -4820,25 +4551,28 @@ dependencies = [ [[package]] name = "tendermint" -version = "0.23.6" -source = "git+https://github.com/heliaxdev/tendermint-rs.git?rev=b7d1e5afc6f2ccb3fd1545c2174bab1cc48d7fa7#b7d1e5afc6f2ccb3fd1545c2174bab1cc48d7fa7" +version = "0.34.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc2294fa667c8b548ee27a9ba59115472d0a09c2ba255771092a7f1dcf03a789" dependencies = [ - "async-trait", "bytes", + "digest 0.10.7", "ed25519", - "ed25519-dalek", + "ed25519-consensus 2.1.0", "flex-error", "futures", + "k256", "num-traits", "once_cell", - "prost 0.11.9", - "prost-types 0.11.9", + "prost 0.12.1", + "prost-types 0.12.1", + "ripemd", "serde", "serde_bytes", "serde_json", "serde_repr", - "sha2 0.9.9", - "signature 1.6.4", + "sha2 0.10.7", + "signature", "subtle 2.4.1", "subtle-encoding", "tendermint-proto", @@ -4848,8 +4582,9 @@ dependencies = [ [[package]] name = "tendermint-config" -version = "0.23.6" -source = "git+https://github.com/heliaxdev/tendermint-rs.git?rev=b7d1e5afc6f2ccb3fd1545c2174bab1cc48d7fa7#b7d1e5afc6f2ccb3fd1545c2174bab1cc48d7fa7" +version = "0.34.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a25dbe8b953e80f3d61789fbdb83bf9ad6c0ef16df5ca6546f49912542cc137" dependencies = [ "flex-error", "serde", @@ -4861,8 +4596,9 @@ dependencies = [ [[package]] name = "tendermint-light-client-verifier" -version = "0.23.6" -source = "git+https://github.com/heliaxdev/tendermint-rs.git?rev=b7d1e5afc6f2ccb3fd1545c2174bab1cc48d7fa7#b7d1e5afc6f2ccb3fd1545c2174bab1cc48d7fa7" +version = "0.34.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74994da9de4b1144837a367ca2c60c650f5526a7c1a54760a3020959b522e474" dependencies = [ "derive_more", "flex-error", @@ -4873,15 +4609,16 @@ dependencies = [ [[package]] name = "tendermint-proto" -version = "0.23.6" -source = "git+https://github.com/heliaxdev/tendermint-rs.git?rev=b7d1e5afc6f2ccb3fd1545c2174bab1cc48d7fa7#b7d1e5afc6f2ccb3fd1545c2174bab1cc48d7fa7" +version = "0.34.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2cc728a4f9e891d71adf66af6ecaece146f9c7a11312288a3107b3e1d6979aaf" dependencies = [ "bytes", "flex-error", "num-derive", "num-traits", - "prost 0.11.9", - "prost-types 0.11.9", + "prost 0.12.1", + "prost-types 0.12.1", "serde", "serde_bytes", "subtle-encoding", @@ -4890,27 +4627,27 @@ dependencies = [ [[package]] name = "tendermint-rpc" -version = "0.23.6" -source = "git+https://github.com/heliaxdev/tendermint-rs.git?rev=b7d1e5afc6f2ccb3fd1545c2174bab1cc48d7fa7#b7d1e5afc6f2ccb3fd1545c2174bab1cc48d7fa7" +version = "0.34.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfbf0a4753b46a190f367337e0163d0b552a2674a6bac54e74f9f2cdcde2969b" dependencies = [ "async-trait", "bytes", "flex-error", - "futures", "getrandom 0.2.9", "peg", "pin-project", + "semver 1.0.18", "serde", "serde_bytes", "serde_json", + "subtle 2.4.1", "subtle-encoding", "tendermint", "tendermint-config", "tendermint-proto", "thiserror", "time 0.3.21", - "tokio", - "tracing", "url", "uuid", "walkdir", @@ -4944,7 +4681,7 @@ checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.39", ] [[package]] @@ -5085,7 +4822,7 @@ checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.39", ] [[package]] @@ -5209,7 +4946,7 @@ checksum = "0f57e3ca2a01450b1a921183a9c9cbfda207fd822cef4ccb00a65402cbba7a74" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.39", ] [[package]] @@ -5416,7 +5153,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.39", "wasm-bindgen-shared", ] @@ -5450,7 +5187,7 @@ checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.39", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -5740,7 +5477,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.39", ] [[package]] diff --git a/packages/shared/lib/Cargo.toml b/packages/shared/lib/Cargo.toml index c64fe64d9e7..c1050c9d4df 100644 --- a/packages/shared/lib/Cargo.toml +++ b/packages/shared/lib/Cargo.toml @@ -24,11 +24,12 @@ gloo-utils = { version = "0.1.5", features = ["serde"] } js-sys = "0.3.60" masp_primitives = { git = "https://github.com/anoma/masp", rev = "77e009626f3f52fe83c81ec6ee38fc2547d38da3" } masp_proofs = { git = "https://github.com/anoma/masp", rev = "77e009626f3f52fe83c81ec6ee38fc2547d38da3", default-features = false, features = ["local-prover"] } -namada = { git = "https://github.com/anoma/namada", version = "0.25.0", default-features = false, features = ["abciplus", "namada-sdk"] } +namada = { git = "https://github.com/anoma/namada", version = "0.26.0", default-features = false, features = ["namada-sdk"] } +proc-macro2 = "1.0.60" prost = "0.9.0" prost-types = "0.9.0" rand = "0.8.5" -serde = "1.0.144" +serde = "^1.0.181" serde_json = "1.0" thiserror = "^1" wasm-bindgen = "0.2.86" diff --git a/packages/shared/lib/src/query.rs b/packages/shared/lib/src/query.rs index 2b45c3750a3..24ade4a84dc 100644 --- a/packages/shared/lib/src/query.rs +++ b/packages/shared/lib/src/query.rs @@ -17,12 +17,7 @@ use namada::namada_sdk::rpc::{ }; use namada::proof_of_stake::Epoch; use namada::types::eth_bridge_pool::TransferToEthereum; -use namada::types::{ - address::Address, - masp::ExtendedViewingKey, - token::{self}, - uint::I256, -}; +use namada::types::{address::Address, masp::ExtendedViewingKey, token, uint::I256}; use std::collections::{HashMap, HashSet}; use std::str::FromStr; use wasm_bindgen::prelude::*; @@ -240,19 +235,15 @@ impl Query { &self, owner: Address, ) -> Result, JsError> { - //TODO: Move hardoced tokens somewhere else - let tokens: HashSet
= HashSet::from([Address::from_str( - "atest1v4ehgw36x3prswzxggunzv6pxqmnvdj9xvcyzvpsggeyvs3cg9qnywf589qnwvfsg5erg3fkl09rg5", - )?, Address::from_str( - "atest1v4ehgw36gfryydj9g3p5zv3kg9znyd358ycnzsfcggc5gvecgc6ygs2rxv6ry3zpg4zrwdfeumqcz9", - )?, Address::from_str( - "atest1v4ehgw36xqmr2d3nx3ryvd2xxgmrq33j8qcns33sxezrgv6zxdzrydjrxveygd2yxumrsdpsf9jc2p", - )?, Address::from_str( - "atest1v46xsw368psnwwf3xcerqeryxcervvpsxuukye3cxsukgce4x5mrwctyvvekvvnxv33nxvfc0kmacx", - )?, - Address::from_str( - "atest1de6hgw368pqnwwf3xcerqeryxcervvpsxuu5y33cxsu5gce4x5mrwc2ygve5vvjxv3pnxvfcq8rzzq", - )?]); + //TODO: Move hardcoded tokens somewhere else + let tokens: HashSet
= HashSet::from([ + // NAM + Address::from_str("tnam1qyytnlley9h2mw5pjzsp862uuqhc2l0h5uqx397y")?, + // DOT + Address::from_str("tnam1qyrsnajxyn660ukm0zwacfrt3mff9c4vvuzrrpnx")?, + // ETH + Address::from_str("tnam1q8r6dc0kh2xuxzjy75cgt4tfqchf4k8cguuvxkuh")?, + ]); let mut result = vec![]; for token in tokens { @@ -480,6 +471,7 @@ impl Query { let is_yay = match vote.data { StorageProposalVote::Yay(_) => true, StorageProposalVote::Nay => false, + StorageProposalVote::Abstain => false, }; (vote.delegator, is_yay) }) diff --git a/packages/shared/lib/src/rpc_client.rs b/packages/shared/lib/src/rpc_client.rs index cdf9f091731..30b1410fb20 100644 --- a/packages/shared/lib/src/rpc_client.rs +++ b/packages/shared/lib/src/rpc_client.rs @@ -8,10 +8,11 @@ use wasm_bindgen_futures::JsFuture; use web_sys::Response; use namada::ledger::queries::{Client, EncodedResponseQuery}; -use namada::tendermint::abci::Code; -use namada::tendermint_rpc::{Response as RpcResponse, SimpleRequest}; +use namada::tendermint::{self, abci::Code}; +use namada::tendermint_rpc::{ + error::Error as TendermintRpcError, Response as RpcResponse, SimpleRequest, +}; use namada::types::storage::BlockHeight; -use namada::{tendermint, tendermint_rpc::error::Error as TendermintRpcError}; #[wasm_bindgen(module = "/src/rpc_client.js")] extern "C" { @@ -128,7 +129,7 @@ impl Client for HttpClient { /// # Arguments /// /// * `request` - request type to be performed. Check `Client` trait for avaialble requests. - async fn perform(&self, request: R) -> Result + async fn perform(&self, request: R) -> Result where R: SimpleRequest, { @@ -147,6 +148,6 @@ impl Client for HttpClient { .expect("JS object to be serializable") .into(); - R::Response::from_string(&response_json) + Ok(R::Response::from_string(&response_json).unwrap().into()) } } diff --git a/packages/shared/lib/src/sdk/mod.rs b/packages/shared/lib/src/sdk/mod.rs index c789858cf37..72751a0bc30 100644 --- a/packages/shared/lib/src/sdk/mod.rs +++ b/packages/shared/lib/src/sdk/mod.rs @@ -10,21 +10,19 @@ use borsh::BorshDeserialize; use namada::ledger::eth_bridge::bridge_pool::build_bridge_pool_tx; use namada::namada_sdk::masp::ShieldedContext; use namada::namada_sdk::rpc::query_epoch; -use namada::namada_sdk::signing::{sign_tx, SigningTxData}; +use namada::namada_sdk::signing::{default_sign, sign_tx, SigningTxData}; use namada::namada_sdk::tx::{ build_bond, build_ibc_transfer, build_reveal_pk, build_transfer, build_unbond, build_vote_proposal, build_withdraw, is_reveal_pk_needed, process_tx, }; +use self::io::WebIo; +use self::wallet::BrowserWalletUtils; use namada::namada_sdk::wallet::{Store, Wallet}; use namada::namada_sdk::{Namada, NamadaImpl}; use namada::types::address::Address; use namada::{proto::Tx, types::key::common::PublicKey}; use wasm_bindgen::{prelude::wasm_bindgen, JsError, JsValue}; - -use self::io::WebIo; -use self::wallet::BrowserWalletUtils; - pub mod io; pub mod masp; mod signature; @@ -48,7 +46,6 @@ pub enum TxType { pub struct BuiltTx { tx: Tx, signing_data: SigningTxData, - is_faucet_transfer: bool, } #[wasm_bindgen] @@ -87,7 +84,7 @@ impl Sdk { &mut self.shielded_ctx, &WebIo, //NAM address - Address::from_str("atest1v4ehgw36x3prswzxggunzv6pxqmnvdj9xvcyzvpsggeyvs3cg9qnywf589qnwvfsg5erg3fkl09rg5").unwrap(), + Address::from_str("tnam1q99c37u38grkdcc2qze0hz4zjjd8zr3yucd3mzgz").unwrap(), ) } @@ -146,7 +143,6 @@ impl Sdk { let BuiltTx { mut tx, signing_data, - is_faucet_transfer, } = built_tx; let mut args = tx::tx_args_from_slice(tx_msg)?; @@ -168,13 +164,10 @@ impl Sdk { let address = Address::from(pk); let namada = self.get_namada(); - let mut wallet = namada.wallet_mut().await; - let reveal_pk_tx_bytes = if !is_faucet_transfer - && is_reveal_pk_needed(namada.client(), &address, false).await? - { + let reveal_pk_tx_bytes = if is_reveal_pk_needed(namada.client(), &address, false).await? { let (mut tx, _, _) = build_reveal_pk(&namada, &args, &pk).await?; - sign_tx(&mut wallet, &args, &mut tx, signing_data.clone())?; + sign_tx(&namada, &args, &mut tx, signing_data.clone(), default_sign).await?; borsh::to_vec(&tx)? } else { @@ -182,7 +175,7 @@ impl Sdk { }; // Sign tx - sign_tx(&mut wallet, &args, &mut tx, signing_data.clone())?; + sign_tx(&namada, &args, &mut tx, signing_data.clone(), default_sign).await?; to_js_result((borsh::to_vec(&tx)?, reveal_pk_tx_bytes)) } @@ -297,16 +290,12 @@ impl Sdk { xsk: Option, _gas_payer: Option, ) -> Result { - let (mut args, faucet_signer) = tx::transfer_tx_args(transfer_msg, tx_msg, password, xsk)?; + let mut args = tx::transfer_tx_args(transfer_msg, tx_msg, password, xsk)?; let namada = self.get_namada(); let (tx, signing_data, _) = build_transfer(&namada, &mut args).await?; - Ok(BuiltTx { - tx, - signing_data, - is_faucet_transfer: faucet_signer.is_some(), - }) + Ok(BuiltTx { tx, signing_data }) } pub async fn build_ibc_transfer( @@ -316,16 +305,12 @@ impl Sdk { password: Option, _gas_payer: Option, ) -> Result { - let (args, faucet_signer) = tx::ibc_transfer_tx_args(ibc_transfer_msg, tx_msg, password)?; + let args = tx::ibc_transfer_tx_args(ibc_transfer_msg, tx_msg, password)?; let namada = self.get_namada(); let (tx, signing_data, _) = build_ibc_transfer(&namada, &args).await?; - Ok(BuiltTx { - tx, - signing_data, - is_faucet_transfer: faucet_signer.is_some(), - }) + Ok(BuiltTx { tx, signing_data }) } pub async fn build_eth_bridge_transfer( @@ -335,17 +320,12 @@ impl Sdk { password: Option, _gas_payer: Option, ) -> Result { - let (args, faucet_signer) = - tx::eth_bridge_transfer_tx_args(eth_bridge_transfer_msg, tx_msg, password)?; + let args = tx::eth_bridge_transfer_tx_args(eth_bridge_transfer_msg, tx_msg, password)?; let namada = self.get_namada(); let (tx, signing_data, _) = build_bridge_pool_tx(&namada, args.clone()).await?; - Ok(BuiltTx { - tx, - signing_data, - is_faucet_transfer: faucet_signer.is_some(), - }) + Ok(BuiltTx { tx, signing_data }) } pub async fn build_vote_proposal( @@ -355,20 +335,15 @@ impl Sdk { password: Option, _gas_payer: Option, ) -> Result { - let (args, faucet_signer) = tx::vote_proposal_tx_args(vote_proposal_msg, tx_msg, password)?; + let args = tx::vote_proposal_tx_args(vote_proposal_msg, tx_msg, password)?; let epoch = query_epoch(&self.client).await?; let namada = self.get_namada(); let (tx, signing_data, _) = build_vote_proposal(&namada, &args, epoch) .await - .map_err(JsError::from)?; - Ok(BuiltTx { - tx, - signing_data, - is_faucet_transfer: faucet_signer.is_some(), - }) + Ok(BuiltTx { tx, signing_data }) } pub async fn build_bond( @@ -378,16 +353,12 @@ impl Sdk { password: Option, _gas_payer: Option, ) -> Result { - let (args, faucet_signer) = tx::bond_tx_args(bond_msg, tx_msg, password)?; + let args = tx::bond_tx_args(bond_msg, tx_msg, password)?; let namada = self.get_namada(); let (tx, signing_data, _) = build_bond(&namada, &args).await?; - Ok(BuiltTx { - tx, - signing_data, - is_faucet_transfer: faucet_signer.is_some(), - }) + Ok(BuiltTx { tx, signing_data }) } pub async fn build_unbond( @@ -397,16 +368,12 @@ impl Sdk { password: Option, _gas_payer: Option, ) -> Result { - let (args, faucet_signer) = tx::unbond_tx_args(unbond_msg, tx_msg, password)?; + let args = tx::unbond_tx_args(unbond_msg, tx_msg, password)?; let namada = self.get_namada(); let (tx, signing_data, _, _) = build_unbond(&namada, &args).await?; - Ok(BuiltTx { - tx, - signing_data, - is_faucet_transfer: faucet_signer.is_some(), - }) + Ok(BuiltTx { tx, signing_data }) } pub async fn build_withdraw( @@ -416,16 +383,12 @@ impl Sdk { password: Option, _gas_payer: Option, ) -> Result { - let (args, faucet_signer) = tx::withdraw_tx_args(withdraw_msg, tx_msg, password)?; + let args = tx::withdraw_tx_args(withdraw_msg, tx_msg, password)?; let namada = self.get_namada(); let (tx, signing_data, _) = build_withdraw(&namada, &args).await?; - Ok(BuiltTx { - tx, - signing_data, - is_faucet_transfer: faucet_signer.is_some(), - }) + Ok(BuiltTx { tx, signing_data }) } async fn build_reveal_pk(&mut self, tx_msg: &[u8], _gas_payer: String) -> Result { diff --git a/packages/shared/lib/src/sdk/tx.rs b/packages/shared/lib/src/sdk/tx.rs index fff0ada6993..0b0d3367ec4 100644 --- a/packages/shared/lib/src/sdk/tx.rs +++ b/packages/shared/lib/src/sdk/tx.rs @@ -8,8 +8,8 @@ use namada::{ address::Address, chain::ChainId, ethereum_events::EthAddress, - key::common::PublicKey as PK, - key::ed25519::PublicKey, + // key::common::PublicKey as PK, + // key::ed25519::PublicKey, masp::{ExtendedSpendingKey, PaymentAddress, TransferSource, TransferTarget}, token::{Amount, DenominatedAmount, NATIVE_MAX_DECIMAL_PLACES}, transaction::GasLimit, @@ -24,7 +24,6 @@ pub struct TxMsg { gas_limit: String, chain_id: String, public_key: Option, - signer: Option, } #[derive(BorshSerialize, BorshDeserialize)] @@ -50,7 +49,7 @@ pub fn bond_tx_args( bond_msg: &[u8], tx_msg: &[u8], password: Option, -) -> Result<(args::Bond, Option
), JsError> { +) -> Result { let bond_msg = SubmitBondMsg::try_from_slice(bond_msg)?; let SubmitBondMsg { @@ -64,7 +63,7 @@ pub fn bond_tx_args( let native_token = Address::from_str(&native_token)?; let validator = Address::from_str(&validator)?; let amount = Amount::from_str(&amount, NATIVE_MAX_DECIMAL_PLACES)?; - let (tx, faucet_signer) = tx_msg_into_args(tx_msg, password)?; + let tx = tx_msg_into_args(tx_msg, password)?; let args = args::Bond { tx, @@ -75,7 +74,7 @@ pub fn bond_tx_args( tx_code_path: PathBuf::from("tx_bond.wasm"), }; - Ok((args, faucet_signer)) + Ok(args) } #[derive(BorshSerialize, BorshDeserialize)] @@ -100,7 +99,7 @@ pub fn unbond_tx_args( unbond_msg: &[u8], tx_msg: &[u8], password: Option, -) -> Result<(args::Unbond, Option
), JsError> { +) -> Result { let unbond_msg = SubmitUnbondMsg::try_from_slice(unbond_msg)?; let SubmitUnbondMsg { @@ -113,7 +112,7 @@ pub fn unbond_tx_args( let validator = Address::from_str(&validator)?; let amount = Amount::from_str(&amount, NATIVE_MAX_DECIMAL_PLACES)?; - let (tx, faucet_signer) = tx_msg_into_args(tx_msg, password)?; + let tx = tx_msg_into_args(tx_msg, password)?; let args = args::Unbond { tx, @@ -123,7 +122,7 @@ pub fn unbond_tx_args( tx_code_path: PathBuf::from("tx_unbond.wasm"), }; - Ok((args, faucet_signer)) + Ok(args) } #[derive(BorshSerialize, BorshDeserialize)] @@ -147,14 +146,14 @@ pub fn withdraw_tx_args( withdraw_msg: &[u8], tx_msg: &[u8], password: Option, -) -> Result<(args::Withdraw, Option
), JsError> { +) -> Result { let withdraw_msg = SubmitWithdrawMsg::try_from_slice(withdraw_msg)?; let SubmitWithdrawMsg { source, validator } = withdraw_msg; let source = Address::from_str(&source)?; let validator = Address::from_str(&validator)?; - let (tx, faucet_signer) = tx_msg_into_args(tx_msg, password)?; + let tx = tx_msg_into_args(tx_msg, password)?; let args = args::Withdraw { tx, @@ -163,7 +162,7 @@ pub fn withdraw_tx_args( tx_code_path: PathBuf::from("tx_withdraw.wasm"), }; - Ok((args, faucet_signer)) + Ok(args) } #[derive(BorshSerialize, BorshDeserialize)] @@ -188,7 +187,7 @@ pub fn vote_proposal_tx_args( vote_proposal_msg: &[u8], tx_msg: &[u8], password: Option, -) -> Result<(args::VoteProposal, Option
), JsError> { +) -> Result { let vote_proposal_msg = SubmitVoteProposalMsg::try_from_slice(vote_proposal_msg)?; let SubmitVoteProposalMsg { @@ -196,7 +195,7 @@ pub fn vote_proposal_tx_args( proposal_id, vote, } = vote_proposal_msg; - let (tx, faucet_signer) = tx_msg_into_args(tx_msg, password)?; + let tx = tx_msg_into_args(tx_msg, password)?; let voter = Address::from_str(&signer)?; let args = args::VoteProposal { @@ -209,7 +208,7 @@ pub fn vote_proposal_tx_args( tx_code_path: PathBuf::from("tx_vote_proposal.wasm"), }; - Ok((args, faucet_signer)) + Ok(args) } #[derive(BorshSerialize, BorshDeserialize)] @@ -237,7 +236,7 @@ pub fn transfer_tx_args( tx_msg: &[u8], password: Option, xsk: Option, -) -> Result<(args::TxTransfer, Option
), JsError> { +) -> Result { let transfer_msg = SubmitTransferMsg::try_from_slice(transfer_msg)?; let SubmitTransferMsg { source, @@ -275,7 +274,7 @@ pub fn transfer_tx_args( let token = Address::from_str(&token)?; let denom_amount = DenominatedAmount::from_str(&amount).expect("Amount to be valid."); let amount = InputAmount::Unvalidated(denom_amount); - let (tx, faucet_signer) = tx_msg_into_args(tx_msg, password)?; + let tx = tx_msg_into_args(tx_msg, password)?; let args = args::TxTransfer { tx, @@ -287,7 +286,7 @@ pub fn transfer_tx_args( tx_code_path: PathBuf::from("tx_transfer.wasm"), }; - Ok((args, faucet_signer)) + Ok(args) } #[derive(BorshSerialize, BorshDeserialize)] @@ -317,7 +316,7 @@ pub fn ibc_transfer_tx_args( ibc_transfer_msg: &[u8], tx_msg: &[u8], password: Option, -) -> Result<(args::TxIbcTransfer, Option
), JsError> { +) -> Result { let ibc_transfer_msg = SubmitIbcTransferMsg::try_from_slice(ibc_transfer_msg)?; let SubmitIbcTransferMsg { source, @@ -336,7 +335,7 @@ pub fn ibc_transfer_tx_args( let amount = InputAmount::Unvalidated(denom_amount); let port_id = PortId::from_str(&port_id).expect("Port id to be valid"); let channel_id = ChannelId::from_str(&channel_id).expect("Channel id to be valid"); - let (tx, faucet_signer) = tx_msg_into_args(tx_msg, password)?; + let tx = tx_msg_into_args(tx_msg, password)?; let args = args::TxIbcTransfer { tx, @@ -352,7 +351,7 @@ pub fn ibc_transfer_tx_args( tx_code_path: PathBuf::from("tx_ibc.wasm"), }; - Ok((args, faucet_signer)) + Ok(args) } #[derive(BorshSerialize, BorshDeserialize)] @@ -371,7 +370,7 @@ pub fn eth_bridge_transfer_tx_args( eth_bridge_transfer_msg: &[u8], tx_msg: &[u8], password: Option, -) -> Result<(args::EthereumBridgePool, Option
), JsError> { +) -> Result { let eth_bridge_transfer_msg = SubmitEthBridgeTransferMsg::try_from_slice(eth_bridge_transfer_msg)?; let SubmitEthBridgeTransferMsg { @@ -385,7 +384,7 @@ pub fn eth_bridge_transfer_tx_args( fee_token, } = eth_bridge_transfer_msg; - let (tx, faucet_signer) = tx_msg_into_args(tx_msg, password)?; + let tx = tx_msg_into_args(tx_msg, password)?; let asset = EthAddress::from_str(&asset).map_err(|e| JsError::new(&format!("{}", e)))?; let recipient = EthAddress::from_str(&recipient).map_err(|e| JsError::new(&format!("{}", e)))?; @@ -411,11 +410,11 @@ pub fn eth_bridge_transfer_tx_args( code_path, }; - Ok((args, faucet_signer)) + Ok(args) } pub fn tx_args_from_slice(tx_msg_bytes: &[u8]) -> Result { - let (args, _) = tx_msg_into_args(tx_msg_bytes, None)?; + let args = tx_msg_into_args(tx_msg_bytes, None)?; Ok(args) } @@ -431,18 +430,14 @@ pub fn tx_args_from_slice(tx_msg_bytes: &[u8]) -> Result { /// # Errors /// /// Returns JsError if token address is invalid. -fn tx_msg_into_args( - tx_msg: &[u8], - password: Option, -) -> Result<(args::Tx, Option
), JsError> { +fn tx_msg_into_args(tx_msg: &[u8], password: Option) -> Result { let tx_msg = TxMsg::try_from_slice(tx_msg)?; let TxMsg { token, fee_amount, gas_limit, chain_id, - public_key, - signer, + public_key: _, } = tx_msg; let token = Address::from_str(&token)?; @@ -452,14 +447,13 @@ fn tx_msg_into_args( let fee_input_amount = InputAmount::Unvalidated(fee_amount); let password = password.map(|pwd| zeroize::Zeroizing::new(pwd)); - let public_key = match public_key { - Some(v) => { - let pk = PublicKey::from_str(&v)?; - Some(PK::Ed25519(pk)) - } - _ => None, - }; - let signer = signer.map(|v| Address::from_str(&v).ok()).flatten(); + // let public_key = match public_key { + // Some(v) => { + // let pk = PublicKey::from_str(&v)?; + // Some(PK::Ed25519(pk)) + // } + // _ => None, + // }; let args = args::Tx { dry_run: false, @@ -482,9 +476,10 @@ fn tx_msg_into_args( signatures: vec![], signing_keys: vec![], tx_reveal_code_path: PathBuf::from("tx_reveal_pk.wasm"), - verification_key: public_key, + use_device: false, + verification_key: None, password, }; - Ok((args, signer)) + Ok(args) } diff --git a/packages/shared/lib/src/sdk/wallet.rs b/packages/shared/lib/src/sdk/wallet.rs index cb88aeb9f5c..c69570a01d0 100644 --- a/packages/shared/lib/src/sdk/wallet.rs +++ b/packages/shared/lib/src/sdk/wallet.rs @@ -1,8 +1,7 @@ use std::str::FromStr; -use masp_primitives::zip32::ExtendedFullViewingKey; use namada::{ - namada_sdk::wallet::{alias::Alias, Store, StoredKeypair, Wallet, WalletIo, WalletStorage}, + namada_sdk::wallet::{alias::Alias, Store, Wallet, WalletIo, WalletStorage}, types::{ address::{Address, ImplicitAddress}, key::{self, common::SecretKey, PublicKeyHash, RefTo}, @@ -79,20 +78,19 @@ pub fn add_key( let sk = SecretKey::Ed25519(sk); let pkh: PublicKeyHash = PublicKeyHash::from(&sk.ref_to()); let password = password.map(|pwd| zeroize::Zeroizing::new(pwd)); - let (keypair_to_store, _raw_keypair) = StoredKeypair::new(sk, password); let address = Address::Implicit(ImplicitAddress(pkh.clone())); let alias: Alias = alias.unwrap_or_else(|| pkh.clone().into()).into(); if wallet .store_mut() - .insert_keypair::(alias.clone(), keypair_to_store, pkh, false) - .is_none() - { - panic!("Action cancelled, no changes persisted."); - } - if wallet - .store_mut() - .insert_address::(alias.clone(), address, false) + .insert_keypair::( + alias.clone(), + sk, + password, + Some(address.clone()), + None, + false, + ) .is_none() { panic!("Action cancelled, no changes persisted."); @@ -116,14 +114,12 @@ pub fn add_spending_key( alias: &str, ) { let xsk = ExtendedSpendingKey::from_str(xsk).expect("XSK deserialization failed."); - let viewkey = ExtendedFullViewingKey::from(&xsk.into()).into(); let password = password.map(|pwd| zeroize::Zeroizing::new(pwd)); - let (spendkey_to_store, _raw_spendkey) = StoredKeypair::new(xsk, password); let alias = Alias::from(alias); if wallet .store_mut() - .insert_spending_key::(alias.clone(), spendkey_to_store, viewkey, false) + .insert_spending_key::(alias.clone(), xsk, password, false) .is_none() { panic!("Action cancelled, no changes persisted."); diff --git a/packages/shared/lib/src/types/address.rs b/packages/shared/lib/src/types/address.rs index 1d28178e1bd..9ddecabedca 100644 --- a/packages/shared/lib/src/types/address.rs +++ b/packages/shared/lib/src/types/address.rs @@ -1,19 +1,28 @@ +use borsh::BorshDeserialize; use namada::types::{ address, key::{ self, common::{PublicKey, SecretKey}, - RefTo, + PublicKeyHash, RefTo, }, }; use std::str::FromStr; use wasm_bindgen::prelude::*; +/// Helper function to bech32 encode a public key from bytes +#[wasm_bindgen] +pub fn public_key_to_bech32(bytes: Vec) -> Result { + let public_key = PublicKey::try_from_slice(&bytes)?; + + Ok(public_key.to_string()) +} + #[wasm_bindgen] pub struct Address { implicit: address::Address, - private: SecretKey, public: PublicKey, + hash: PublicKeyHash, } #[wasm_bindgen] @@ -27,12 +36,13 @@ impl Address { #[allow(clippy::useless_conversion)] let public = PublicKey::from(private.ref_to()); + let hash = PublicKeyHash::from(&public); let implicit = address::Address::Implicit(address::ImplicitAddress::from(&public)); Address { implicit, - private, public, + hash, } } @@ -44,8 +54,8 @@ impl Address { self.public.to_string() } - pub fn private(&self) -> String { - self.private.to_string() + pub fn hash(&self) -> String { + self.hash.to_string() } } @@ -60,10 +70,7 @@ mod tests { let address = Address::new(secret); let implicit = address.implicit(); - assert_eq!( - implicit, - "atest1d9khqw36x5cnvvjpgfzyxsjpgfqnqwf5xpq5zv34gvunswp4g3znww2yxqursdpnxdz5yw2ypna253" - ); + assert_eq!(implicit, "tnam1qpgk927uh2aqjs92yhycsh08n5yggvltn5nk92zp"); assert_eq!(implicit.len(), address::ADDRESS_LEN); } @@ -73,24 +80,22 @@ mod tests { String::from("1498b5467a63dffa2dc9d9e069caf075d16fc33fdd4c3b01bfadae6433767d93"); let address = Address::new(secret); let public = address.public(); - let pad = "00"; assert_eq!( public, - "pktest1qzm68sfdcryvwj9tqaf9kuq3y2ugh4u0vqx8vdpdyle9uhujg3xdurhznu9" + "tpknam1qzm68sfdcryvwj9tqaf9kuq3y2ugh4u0vqx8vdpdyle9uhujg3xduf408cn" ); - assert_eq!(public.len(), pad.len() + 64); + assert_eq!(public.len(), 66); } #[test] - fn can_return_correct_secret_key() { + fn can_return_correct_public_key_hash() { let secret = String::from("1498b5467a63dffa2dc9d9e069caf075d16fc33fdd4c3b01bfadae6433767d93"); let address = Address::new(secret.clone()); - let private = address.private(); - let pad = "00"; + let hash = address.hash(); - assert_eq!(format!("{}{}", pad, secret), private); - assert_eq!(private.len(), pad.len() + 64); + assert_eq!("5162ABDCBABA0940AA25C9885DE79D088433EB9D", hash); + assert_eq!(hash.len(), 40); } } diff --git a/packages/shared/lib/src/types/masp.rs b/packages/shared/lib/src/types/masp.rs index 117358d33fc..99dc7d84460 100644 --- a/packages/shared/lib/src/types/masp.rs +++ b/packages/shared/lib/src/types/masp.rs @@ -124,12 +124,12 @@ mod tests { let expected_key = format!( "{}{}{}", - "xsktest1q85aawymqyqqqq8gt6pzjzf6c53lt70gu80zd9rfes8wv8h3zmtzdhf3zxfllzxmlfr7dcszjf94a602l6qga52fgx6yp6ul", - "05vy6r8kwxhznkg9hmtsvn9axu0kq4tjzmtl4rrz5f0uhx45qrnj3tpy3y0gad0p376xapcz6k676e3hkt9qy7apdqc4kff7xjzysec8", - "83h2kvgkvjfzcn7dwqvjgvlzuskl9jwu6nwr5hrl9ltrht4kffdyredmf3qlvghdd0gt9uc8v6hz3", + "zsknam1q85aawymqyqqqq8gt6pzjzf6c53lt70gu80zd9rfes8wv8h3zmtzdhf3zxfllzxmlfr7dcszjf94a602l6qga52fgx6yp6ul05vy6r", + "8kwxhznkg9hmtsvn9axu0kq4tjzmtl4rrz5f0uhx45qrnj3tpy3y0gad0p376xapcz6k676e3hkt9qy7apdqc4kff7xjzysec883h2kvgkvjf", + "zcn7dwqvjgvlzuskl9jwu6nwr5hrl9ltrht4kffdyredmf3qlvghdd0gt9ucw4ccj7", ); - assert!(key.starts_with("xsktest")); + assert!(key.starts_with("zsknam")); assert_eq!(key, expected_key); } @@ -154,11 +154,11 @@ mod tests { let expected_key = format!( "{}{}{}", - "xfvktest1q85aawymqyqqqq8gt6pzjzf6c53lt70gu80zd9rfes8wv8h3zmtzdhf3zxfllzxmltncmlfp35kjll27vvpr4625nz8rctd", - "0vs9q2gr7s5hdvv5ga0ayjltsv7880nxdfv0dqa7lmgf43n4dh86wfcpqdrqmmlcfjvtptu9l6k676e3hkt9qy7apdqc4kff7xjzysec8", - "83h2kvgkvjfzcn7dwqvjgvlzuskl9jwu6nwr5hrl9ltrht4kffdyredmf3qlvghdd0gt9ucvxyquf", + "zvknam1q85aawymqyqqqq8gt6pzjzf6c53lt70gu80zd9rfes8wv8h3zmtzdhf3zxfllzxmltncmlfp35kjll27vvpr4625nz8rctd0vs9", + "q2gr7s5hdvv5ga0ayjltsv7880nxdfv0dqa7lmgf43n4dh86wfcpqdrqmmlcfjvtptu9l6k676e3hkt9qy7apdqc4kff7xjzysec883h2k", + "vgkvjfzcn7dwqvjgvlzuskl9jwu6nwr5hrl9ltrht4kffdyredmf3qlvghdd0gt9uce7vx4v", ); - assert!(key.starts_with("xfvktest")); + assert!(key.starts_with("zvknam")); assert_eq!(key, expected_key); } @@ -177,10 +177,11 @@ mod tests { let hash = payment_address.hash(); let expected_address = - "patest1vnrjyczagvf9745t002cmeyn48d0wj6ncdyyjtzpare7t5flkuq4w47t9z60yeam7hszga07g7t"; + "znam1qpjvwgnqt4p3yh6k3daatr0yjw5a4a6t20p5sjfvg8508ew387msz46hev5tfun8h067qfqh3s64t"; + let expected_hash = "DBF7C3440E0C0B81EBBB95AD26DA6D875C19BC45"; - assert!(address.starts_with("patest")); + assert!(address.starts_with("znam")); assert_eq!(address, expected_address); assert_eq!(hash, expected_hash); } diff --git a/packages/types/package.json b/packages/types/package.json index 60d80206d50..111598d59db 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -16,7 +16,7 @@ "@namada/ledger-namada": "0.0.1", "bn.js": "^5.2.1", "@dao-xyz/borsh": "^5.1.5", - "slip44": "^2.0.4", + "slip44": "^3.0.11", "typescript": "^5.1.3" }, "devDependencies": { diff --git a/packages/types/src/tx/schema/tx.ts b/packages/types/src/tx/schema/tx.ts index 6a766b67da7..6c1a885f141 100644 --- a/packages/types/src/tx/schema/tx.ts +++ b/packages/types/src/tx/schema/tx.ts @@ -20,9 +20,6 @@ export class TxMsgValue { @field({ type: option("string") }) publicKey?: string; - @field({ type: option("string") }) - signer?: string; - constructor(data: TxProps) { Object.assign(this, data); } diff --git a/packages/types/src/tx/tokens/types/index.ts b/packages/types/src/tx/tokens/types/index.ts index e60b14c0601..276830a69bc 100644 --- a/packages/types/src/tx/tokens/types/index.ts +++ b/packages/types/src/tx/tokens/types/index.ts @@ -1,8 +1,4 @@ -import { - registeredCoinTypes, - RegisteredCoinType, - RegisteredCoinSymbol, -} from "slip44"; +import { registeredCoinTypes, RegisteredCoinType } from "slip44"; export type TokenInfo = { symbol: string; @@ -17,37 +13,15 @@ export type TokenInfo = { }; // Declare symbols for tokens we support: -export const Symbols = [ - "NAM", - "ATOM", - "ETH", - "TESTERC20", - "NUTTESTERC20", -] as const; +export const Symbols = ["NAM", "ATOM", "ETH"] as const; -export type TokenType = (typeof Symbols)[number]; +export type TokenType = typeof Symbols[number]; type Tokens = Record; -const nuterc20 = [ - -999, - -999, - "NUTTESTERC20" as RegisteredCoinSymbol, - "NUTtesterc20", -] as RegisteredCoinType; - -const erc20 = [ - -999, - -999, - "TESTERC20" as RegisteredCoinSymbol, - "testerc20", -] as RegisteredCoinType; - const supportedCoinTypes: RegisteredCoinType[] = [ ...registeredCoinTypes.filter(([, , symbol]) => { return Symbols.indexOf(`${symbol as TokenType}`) > -1; }), - erc20, - nuterc20, ]; export const Tokens = supportedCoinTypes.reduce( @@ -70,34 +44,23 @@ export const Tokens = supportedCoinTypes.reduce( // Map a few test addresses for now: Tokens["NAM"] = { - type: 123456, - path: 2147483651, - symbol: "NAM", - coin: "Namada", + ...Tokens["NAM"], url: "https://namada.net", - address: - "atest1v4ehgw36x3prswzxggunzv6pxqmnvdj9xvcyzvpsggeyvs3cg9qnywf589qnwvfsg5erg3fkl09rg5", + address: "tnam1qyytnlley9h2mw5pjzsp862uuqhc2l0h5uqx397y", }; -Tokens["ATOM"].address = - "atest1v4ehgw36gfryydj9g3p5zv3kg9znyd358ycnzsfcggc5gvecgc6ygs2rxv6ry3zpg4zrwdfeumqcz9"; -Tokens["ATOM"].coinGeckoId = "cosmos"; - -Tokens["ETH"].address = - "atest1v4ehgw36xqmr2d3nx3ryvd2xxgmrq33j8qcns33sxezrgv6zxdzrydjrxveygd2yxumrsdpsf9jc2p"; -Tokens["ETH"].coinGeckoId = "ethereum"; - -Tokens["TESTERC20"].address = - "atest1v46xsw368psnwwf3xcerqeryxcervvpsxuukye3cxsukgce4x5mrwctyvvekvvnxv33nxvfc0kmacx"; -Tokens["TESTERC20"].nativeAddress = - "0x8A791620dd6260079BF849Dc5567aDC3F2FdC318"; -Tokens["TESTERC20"].coinGeckoId = "testerc20"; +// TODO: We don't have a address for this. The address for DOT +// from the dev & e2e genesis is being used here: +Tokens["ATOM"] = { + ...Tokens["ATOM"], + address: "tnam1qyrsnajxyn660ukm0zwacfrt3mff9c4vvuzrrpnx", + coinGeckoId: "cosmos", +}; -Tokens["NUTTESTERC20"].address = - "atest1de6hgw368psnwwf3xcerqeryxcervvpsxuukye3cxsukgce4x5mrwctyvvekvvnxv33nxvfcmh3pul"; -Tokens["NUTTESTERC20"].nativeAddress = - "0x8A791620dd6260079BF849Dc5567aDC3F2FdC318"; -Tokens["NUTTESTERC20"].isNut = true; -Tokens["NUTTESTERC20"].coinGeckoId = "NUTtesterc20"; +Tokens["ETH"] = { + ...Tokens["ETH"], + address: "tnam1q8r6dc0kh2xuxzjy75cgt4tfqchf4k8cguuvxkuh", + coinGeckoId: "ethereum", +}; export type TokenBalance = { token: TokenType; amount: string }; diff --git a/packages/utils/src/helpers/index.ts b/packages/utils/src/helpers/index.ts index a379943f794..067c0044703 100644 --- a/packages/utils/src/helpers/index.ts +++ b/packages/utils/src/helpers/index.ts @@ -189,9 +189,7 @@ export const makeBip44Path = ( bip44Path: Bip44Path ): string => { const { account, change, index } = bip44Path; - const basePath = `m/44'/${coinType}'/${account}'/${change}`; - - return typeof index === "number" ? `${basePath}/${index}` : basePath; + return `m/44'/${coinType}'/${account}'/${change}'/${index}'`; }; /** diff --git a/yarn.lock b/yarn.lock index 57d935355ef..1a00fe5c5c3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -18197,10 +18197,10 @@ slash@^4.0.0: resolved "https://registry.yarnpkg.com/slash/-/slash-4.0.0.tgz#2422372176c4c6c5addb5e2ada885af984b396a7" integrity sha512-3dOsAHXXUkQTpOYcoAxLIorMTp4gIQr5IW3iVb7A7lFIp0VHhnynm9izx6TssdrIcVIESAlVjtnO2K8bg+Coew== -slip44@^2.0.4: - version "2.0.4" - resolved "https://registry.yarnpkg.com/slip44/-/slip44-2.0.4.tgz#68f5a46d4cdd368609f91e9f9453d7a933706046" - integrity sha512-WX7y7PNkxQh7G/4BFogHqXxbb2+TbV47ThaL3BNJ5PE31asPJWARKqk8KYZZibXgp+th3MSdksZRL22m7FE5Ww== +slip44@^3.0.11: + version "3.0.11" + resolved "https://registry.yarnpkg.com/slip44/-/slip44-3.0.11.tgz#08358a4ffb2139f3ad03cfb02fdff706d998a30b" + integrity sha512-riJHapPOLXgmLbPrRiJFu/GZkeVFCQpl772uky34BGZ9bPABYst3dYPu+5dENBf55qUW1dLU8g+ZCnHETyWWIg== smart-buffer@^4.2.0: version "4.2.0"