From a6ce929eee60796a575310e0462eae494784c9c9 Mon Sep 17 00:00:00 2001 From: Bhavi Dhingra Date: Wed, 18 Sep 2024 14:15:18 +0200 Subject: [PATCH] feat(sui): add sui token support --- electron/main/index.ts | 2 +- package-lock.json | 482 +++++++++++++----- package.json | 4 +- .../BuildUnsignedConsolidationCoin.tsx | 61 ++- .../SuiTokenForm.tsx | 136 +++++ .../BuildUnsignedSweepCoin.tsx | 68 +++ .../BuildUnsignedSweepCoin/SuiTokenForm.tsx | 93 ++++ .../CreateBroadcastableTransactionIndex.tsx | 3 +- .../NonBitGoRecoveryCoin.tsx | 4 +- src/helpers/config.ts | 22 + src/utils/types.ts | 2 +- 11 files changed, 743 insertions(+), 134 deletions(-) create mode 100644 src/containers/BuildUnsignedConsolidation/SuiTokenForm.tsx create mode 100644 src/containers/BuildUnsignedSweepCoin/SuiTokenForm.tsx diff --git a/electron/main/index.ts b/electron/main/index.ts index 5052db9a..22442c92 100644 --- a/electron/main/index.ts +++ b/electron/main/index.ts @@ -60,7 +60,7 @@ import * as ecc from 'tiny-secp256k1'; import { Hbar, Thbar } from '@bitgo/sdk-coin-hbar'; import { Algo, Talgo } from '@bitgo/sdk-coin-algo'; import { EthLikeCoin, TethLikeCoin } from '@bitgo/sdk-coin-ethlike'; -import { Sui, Tsui } from '@bitgo/sdk-coin-sui'; +import { Sui, Tsui } from '@bitgo-beta/sdk-coin-sui'; import { loadWebAssembly } from '@bitgo/sdk-opensslbytes'; const bip32 = BIP32Factory(ecc); diff --git a/package-lock.json b/package-lock.json index ac7dcff4..9b1345eb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,6 +9,7 @@ "version": "0.0.0-placeholder-version", "license": "Apache-2.0", "dependencies": { + "@bitgo-beta/sdk-coin-sui": "^1.4.1-alpha.204", "@bitgo/abstract-cosmos": "11.0.4", "@bitgo/abstract-utxo": "8.14.1", "@bitgo/sdk-api": "1.54.0", @@ -43,7 +44,6 @@ "@bitgo/sdk-coin-polygon": "21.0.4", "@bitgo/sdk-coin-sei": "3.0.4", "@bitgo/sdk-coin-sol": "4.5.1", - "@bitgo/sdk-coin-sui": "5.6.3", "@bitgo/sdk-coin-tia": "3.0.4", "@bitgo/sdk-coin-trx": "2.0.35", "@bitgo/sdk-coin-xlm": "3.2.9", @@ -2336,6 +2336,363 @@ "dev": true, "license": "MIT" }, + "node_modules/@bitgo-beta/blake2b": { + "version": "3.2.1-alpha.206", + "resolved": "https://registry.npmjs.org/@bitgo-beta/blake2b/-/blake2b-3.2.1-alpha.206.tgz", + "integrity": "sha512-4zZ7jba7sW8zg4WTuYUXECvTQvWqJevvGI/+16wDmFpsflLPpbLJ+CxUkHaMPpY5Yj6YryS8CI7xrClthzuixA==", + "dependencies": { + "@bitgo-beta/blake2b-wasm": "3.2.1-alpha.207", + "nanoassert": "^2.0.0" + } + }, + "node_modules/@bitgo-beta/blake2b-wasm": { + "version": "3.2.1-alpha.207", + "resolved": "https://registry.npmjs.org/@bitgo-beta/blake2b-wasm/-/blake2b-wasm-3.2.1-alpha.207.tgz", + "integrity": "sha512-LAXFHK6DreTu09BcoFesbfxiQWDvH6B2tg+lYAAhsJNOgC31tQmX8bxMaRqq34rDaa7N5rRdUUqe945KgWosjg==", + "dependencies": { + "nanoassert": "^1.0.0" + } + }, + "node_modules/@bitgo-beta/blake2b-wasm/node_modules/nanoassert": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/nanoassert/-/nanoassert-1.1.0.tgz", + "integrity": "sha512-C40jQ3NzfkP53NsO8kEOFd79p4b9kDXQMwgiY1z8ZwrDZgUyom0AHwGegF4Dm99L+YoYhuaB0ceerUcXmqr1rQ==" + }, + "node_modules/@bitgo-beta/bls-dkg": { + "version": "1.3.1-alpha.207", + "resolved": "https://registry.npmjs.org/@bitgo-beta/bls-dkg/-/bls-dkg-1.3.1-alpha.207.tgz", + "integrity": "sha512-mj/0Zn+5QTdrXkQ561Vr2dZ0kbGvLKccIRO/VlCDXc2nK6oJxLBWgWessTgzoJbzpqsSk145Wrc1lVujYFy2aQ==", + "dependencies": { + "noble-bls12-381": "^0.7.2" + } + }, + "node_modules/@bitgo-beta/sdk-coin-sui": { + "version": "1.4.1-alpha.204", + "resolved": "https://registry.npmjs.org/@bitgo-beta/sdk-coin-sui/-/sdk-coin-sui-1.4.1-alpha.204.tgz", + "integrity": "sha512-12x7eyh3DH3TPHSr3V6lTtczaK0lJsO+i55kwfuQK1IIETWy1VubiLjT/0FQ4p8tjF93GySq5EFt5DkhfBvJjw==", + "dependencies": { + "@bitgo-beta/blake2b": "3.2.1-alpha.206", + "@bitgo-beta/sdk-core": "2.4.1-alpha.205", + "@bitgo-beta/sdk-lib-mpc": "8.2.1-alpha.161", + "@bitgo-beta/statics": "10.0.1-alpha.205", + "@mysten/bcs": "^0.7.0", + "bignumber.js": "^9.0.0", + "bs58": "^4.0.1", + "lodash": "^4.17.21", + "superagent": "3.8.2", + "superstruct": "^1.0.3", + "tweetnacl": "^1.0.3" + }, + "engines": { + "node": ">=18 <21" + } + }, + "node_modules/@bitgo-beta/sdk-coin-sui/node_modules/debug": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "dependencies": { + "ms": "^2.1.1" + } + }, + "node_modules/@bitgo-beta/sdk-coin-sui/node_modules/form-data": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.5.1.tgz", + "integrity": "sha512-m21N3WOmEEURgk6B9GLOE4RuWOFf28Lhh9qGYeNlGq4VDXUlJy2th2slBNU8Gp8EzloYZOibZJ7t5ecIrFSjVA==", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.6", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 0.12" + } + }, + "node_modules/@bitgo-beta/sdk-coin-sui/node_modules/formidable": { + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/formidable/-/formidable-1.2.6.tgz", + "integrity": "sha512-KcpbcpuLNOwrEjnbpMC0gS+X8ciDoZE1kkqzat4a8vrprf+s9pKNQ/QIwWfbfs4ltgmFl3MD177SNTkve3BwGQ==", + "deprecated": "Please upgrade to latest, formidable@v2 or formidable@v3! Check these notes: https://bit.ly/2ZEqIau", + "funding": { + "url": "https://ko-fi.com/tunnckoCore/commissions" + } + }, + "node_modules/@bitgo-beta/sdk-coin-sui/node_modules/isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==" + }, + "node_modules/@bitgo-beta/sdk-coin-sui/node_modules/mime": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", + "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==", + "bin": { + "mime": "cli.js" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/@bitgo-beta/sdk-coin-sui/node_modules/readable-stream": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.8.tgz", + "integrity": "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==", + "dependencies": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "node_modules/@bitgo-beta/sdk-coin-sui/node_modules/safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + }, + "node_modules/@bitgo-beta/sdk-coin-sui/node_modules/string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dependencies": { + "safe-buffer": "~5.1.0" + } + }, + "node_modules/@bitgo-beta/sdk-coin-sui/node_modules/superagent": { + "version": "3.8.2", + "resolved": "https://registry.npmjs.org/superagent/-/superagent-3.8.2.tgz", + "integrity": "sha512-gVH4QfYHcY3P0f/BZzavLreHW3T1v7hG9B+hpMQotGQqurOvhv87GcMCd6LWySmBuf+BDR44TQd0aISjVHLeNQ==", + "deprecated": "Please upgrade to v9.0.0+ as we have fixed a public vulnerability with formidable dependency. Note that v9.0.0+ requires Node.js v14.18.0+. See https://github.com/ladjs/superagent/pull/1800 for insight. This project is supported and maintained by the team at Forward Email @ https://forwardemail.net", + "dependencies": { + "component-emitter": "^1.2.0", + "cookiejar": "^2.1.0", + "debug": "^3.1.0", + "extend": "^3.0.0", + "form-data": "^2.3.1", + "formidable": "^1.1.1", + "methods": "^1.1.1", + "mime": "^1.4.1", + "qs": "^6.5.1", + "readable-stream": "^2.0.5" + }, + "engines": { + "node": ">= 4.0" + } + }, + "node_modules/@bitgo-beta/sdk-coin-sui/node_modules/superstruct": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/superstruct/-/superstruct-1.0.4.tgz", + "integrity": "sha512-7JpaAoX2NGyoFlI9NBh66BQXGONc+uE+MRS5i2iOBKuS4e+ccgMDjATgZldkah+33DakBxDHiss9kvUcGAO8UQ==", + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@bitgo-beta/sdk-core": { + "version": "2.4.1-alpha.205", + "resolved": "https://registry.npmjs.org/@bitgo-beta/sdk-core/-/sdk-core-2.4.1-alpha.205.tgz", + "integrity": "sha512-fZVbEST/TZKGqRvbjXL2VwV6jlyk47+mGjLJR7lcfsr1fXTS5fX2d0RmeI09hplL8PU7aLSuftjNwWlKXdzhSQ==", + "dependencies": { + "@bitgo-beta/bls-dkg": "1.3.1-alpha.207", + "@bitgo-beta/sdk-lib-mpc": "8.2.1-alpha.161", + "@bitgo-beta/sjcl": "1.0.1-alpha.155", + "@bitgo-beta/statics": "10.0.1-alpha.205", + "@bitgo-beta/utxo-lib": "4.0.1-alpha.206", + "@bitgo/public-types": "2.33.4", + "@noble/secp256k1": "1.6.3", + "@stablelib/hex": "^1.0.0", + "@types/elliptic": "^6.4.12", + "@types/superagent": "4.1.15", + "bech32": "^2.0.0", + "big.js": "^3.1.3", + "bigint-crypto-utils": "3.1.4", + "bignumber.js": "^9.1.1", + "bitcoinjs-message": "npm:@bitgo-forks/bitcoinjs-message@1.0.0-master.2", + "bolt11": "^1.4.0", + "bs58": "^4.0.1", + "bs58check": "^2.1.2", + "create-hmac": "^1.1.7", + "debug": "^3.1.0", + "elliptic": "^6.5.2", + "ethereumjs-util": "7.1.5", + "fp-ts": "^2.12.2", + "io-ts": "2.1.3", + "io-ts-types": "0.5.16", + "keccak": "3.0.3", + "libsodium-wrappers-sumo": "^0.7.9", + "lodash": "^4.17.15", + "macaroon": "^3.0.4", + "noble-bls12-381": "0.7.2", + "openpgp": "5.10.1", + "paillier-bigint": "3.3.0", + "secp256k1": "5.0.0", + "strip-hex-prefix": "^1.0.0", + "superagent": "^9.0.1", + "tweetnacl": "^1.0.3", + "uuid": "^8.3.2" + } + }, + "node_modules/@bitgo-beta/sdk-core/node_modules/debug": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "dependencies": { + "ms": "^2.1.1" + } + }, + "node_modules/@bitgo-beta/sdk-core/node_modules/keccak": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/keccak/-/keccak-3.0.3.tgz", + "integrity": "sha512-JZrLIAJWuZxKbCilMpNz5Vj7Vtb4scDG3dMXLOsbzBmQGyjwE61BbW7bJkfKKCShXiQZt3T6sBgALRtmd+nZaQ==", + "hasInstallScript": true, + "dependencies": { + "node-addon-api": "^2.0.0", + "node-gyp-build": "^4.2.0", + "readable-stream": "^3.6.0" + }, + "engines": { + "node": ">=10.0.0" + } + }, + "node_modules/@bitgo-beta/sdk-core/node_modules/node-addon-api": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-2.0.2.tgz", + "integrity": "sha512-Ntyt4AIXyaLIuMHF6IOoTakB3K+RWxwtsHNRxllEoA6vPwP9o4866g6YWDLUdnucilZhmkxiHwHr11gAENw+QA==" + }, + "node_modules/@bitgo-beta/sdk-core/node_modules/secp256k1": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/secp256k1/-/secp256k1-5.0.0.tgz", + "integrity": "sha512-TKWX8xvoGHrxVdqbYeZM9w+izTF4b9z3NhSaDkdn81btvuh+ivbIMGT/zQvDtTFWhRlThpoz6LEYTr7n8A5GcA==", + "hasInstallScript": true, + "dependencies": { + "elliptic": "^6.5.4", + "node-addon-api": "^5.0.0", + "node-gyp-build": "^4.2.0" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@bitgo-beta/sdk-core/node_modules/secp256k1/node_modules/node-addon-api": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-5.1.0.tgz", + "integrity": "sha512-eh0GgfEkpnoWDq+VY8OyvYhFEzBk6jIYbRKdIlyTiAXIVJ8PyBaKb0rp7oDtoddbdoHWhq8wwr+XZ81F1rpNdA==" + }, + "node_modules/@bitgo-beta/sdk-lib-mpc": { + "version": "8.2.1-alpha.161", + "resolved": "https://registry.npmjs.org/@bitgo-beta/sdk-lib-mpc/-/sdk-lib-mpc-8.2.1-alpha.161.tgz", + "integrity": "sha512-Ajm3cyJ2UCILUkOUiask+tUtw/SHFdp5YqxmZT2hjPBjvhYa08pD+mijQAihzLdK+ZorjR+3wZMw4ZMt4wjAMg==", + "dependencies": { + "@noble/curves": "1.4.0", + "@silencelaboratories/dkls-wasm-ll-node": "1.1.2", + "@silencelaboratories/dkls-wasm-ll-web": "1.1.2", + "@types/superagent": "4.1.15", + "@wasmer/wasi": "^1.2.2", + "bigint-crypto-utils": "3.1.4", + "bigint-mod-arith": "3.1.2", + "cbor-x": "1.5.9", + "fp-ts": "2.16.2", + "io-ts": "2.1.3", + "libsodium-wrappers-sumo": "^0.7.9", + "openpgp": "5.10.1", + "paillier-bigint": "3.3.0", + "secp256k1": "5.0.0" + }, + "peerDependencies": { + "@silencelaboratories/dkls-wasm-ll-bundler": "1.1.2" + }, + "peerDependenciesMeta": { + "@silencelaboratories/dkls-wasm-ll-bundler": { + "optional": true + } + } + }, + "node_modules/@bitgo-beta/sdk-lib-mpc/node_modules/@noble/curves": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.4.0.tgz", + "integrity": "sha512-p+4cb332SFCrReJkCYe8Xzm0OWi4Jji5jVdIZRL/PmacmDkFNw6MrrV+gGpiPxLHbV+zKFRywUWbaseT+tZRXg==", + "dependencies": { + "@noble/hashes": "1.4.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@bitgo-beta/sdk-lib-mpc/node_modules/@noble/hashes": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.4.0.tgz", + "integrity": "sha512-V1JJ1WTRUqHHrOSh597hURcMqVKVGL/ea3kv0gSnEdsEZ0/+VyPghM1lMNGc00z7CIQorSvbKpuJkxvuHbvdbg==", + "engines": { + "node": ">= 16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@bitgo-beta/sdk-lib-mpc/node_modules/fp-ts": { + "version": "2.16.2", + "resolved": "https://registry.npmjs.org/fp-ts/-/fp-ts-2.16.2.tgz", + "integrity": "sha512-CkqAjnIKFqvo3sCyoBTqgJvF+bHrSik584S9nhTjtBESLx26cbtVMR/T9a6ApChOcSDAaM3JydDmWDUn4EEXng==" + }, + "node_modules/@bitgo-beta/sdk-lib-mpc/node_modules/node-addon-api": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-5.1.0.tgz", + "integrity": "sha512-eh0GgfEkpnoWDq+VY8OyvYhFEzBk6jIYbRKdIlyTiAXIVJ8PyBaKb0rp7oDtoddbdoHWhq8wwr+XZ81F1rpNdA==" + }, + "node_modules/@bitgo-beta/sdk-lib-mpc/node_modules/secp256k1": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/secp256k1/-/secp256k1-5.0.0.tgz", + "integrity": "sha512-TKWX8xvoGHrxVdqbYeZM9w+izTF4b9z3NhSaDkdn81btvuh+ivbIMGT/zQvDtTFWhRlThpoz6LEYTr7n8A5GcA==", + "hasInstallScript": true, + "dependencies": { + "elliptic": "^6.5.4", + "node-addon-api": "^5.0.0", + "node-gyp-build": "^4.2.0" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@bitgo-beta/sjcl": { + "version": "1.0.1-alpha.155", + "resolved": "https://registry.npmjs.org/@bitgo-beta/sjcl/-/sjcl-1.0.1-alpha.155.tgz", + "integrity": "sha512-hi59+nCO5Yv61byuPhHYk8GaAjGAfs4zQmW0m+ioocz48q3NDs5QqziGTA7HM/YMMgbBfBCJtIbezrEgyk25vw==" + }, + "node_modules/@bitgo-beta/statics": { + "version": "10.0.1-alpha.205", + "resolved": "https://registry.npmjs.org/@bitgo-beta/statics/-/statics-10.0.1-alpha.205.tgz", + "integrity": "sha512-hchrl+mJlrb0iZhownRi2RbVRbBOoXANPCrsPmKpGE8URJeHk35ed2zDjRVdSkqwwh/dmFjarp9vl0SHjkcoNg==" + }, + "node_modules/@bitgo-beta/utxo-lib": { + "version": "4.0.1-alpha.206", + "resolved": "https://registry.npmjs.org/@bitgo-beta/utxo-lib/-/utxo-lib-4.0.1-alpha.206.tgz", + "integrity": "sha512-k41E7zqLipKGX1Dlx3y8DZf9vaZfC/W8SsBosfb7gejTHgBSMjy2h7RreX6arW2cmFzcTvyjA6tYQFC3MI7FbQ==", + "dependencies": { + "@bitgo-beta/blake2b": "3.2.1-alpha.206", + "@brandonblack/musig": "^0.0.1-alpha.0", + "@noble/secp256k1": "1.6.3", + "bech32": "^2.0.0", + "bip174": "npm:@bitgo-forks/bip174@3.1.0-master.4", + "bip32": "^3.0.1", + "bitcoin-ops": "^1.3.0", + "bitcoinjs-lib": "npm:@bitgo-forks/bitcoinjs-lib@7.1.0-master.9", + "bn.js": "^5.2.1", + "bs58check": "^2.1.2", + "cashaddress": "^1.1.0", + "create-hash": "^1.2.0", + "create-hmac": "^1.1.7", + "ecpair": "npm:@bitgo/ecpair@2.1.0-rc.0", + "elliptic": "^6.5.2", + "fastpriorityqueue": "^0.7.1", + "typeforce": "^1.11.3", + "varuint-bitcoin": "^1.1.2" + }, + "engines": { + "node": ">=10.22.0 <21", + "npm": ">=3.10.10" + } + }, "node_modules/@bitgo-forks/avalanchejs": { "version": "4.1.0-alpha.1", "resolved": "https://registry.npmjs.org/@bitgo-forks/avalanchejs/-/avalanchejs-4.1.0-alpha.1.tgz", @@ -4300,129 +4657,6 @@ "webidl-conversions": "^3.0.0" } }, - "node_modules/@bitgo/sdk-coin-sui": { - "version": "5.6.3", - "resolved": "https://registry.npmjs.org/@bitgo/sdk-coin-sui/-/sdk-coin-sui-5.6.3.tgz", - "integrity": "sha512-6EcCWpB2ftvtKkoS/hvx5pL7UB6HoFlX4mG27U1gdedkq+7K1fH7BUxFjsH9VCz4Q8OH/Cly8BeJ9gGXL5pHhg==", - "dependencies": { - "@bitgo/blake2b": "^3.2.4", - "@bitgo/sdk-core": "^28.4.0", - "@bitgo/sdk-lib-mpc": "^10.0.0", - "@bitgo/statics": "^49.4.0", - "@mysten/bcs": "^0.7.0", - "bignumber.js": "^9.0.0", - "bs58": "^4.0.1", - "lodash": "^4.17.21", - "superagent": "3.8.2", - "superstruct": "^1.0.3", - "tweetnacl": "^1.0.3" - }, - "engines": { - "node": ">=18 <21" - } - }, - "node_modules/@bitgo/sdk-coin-sui/node_modules/debug": { - "version": "3.2.7", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", - "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", - "dependencies": { - "ms": "^2.1.1" - } - }, - "node_modules/@bitgo/sdk-coin-sui/node_modules/form-data": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.5.1.tgz", - "integrity": "sha512-m21N3WOmEEURgk6B9GLOE4RuWOFf28Lhh9qGYeNlGq4VDXUlJy2th2slBNU8Gp8EzloYZOibZJ7t5ecIrFSjVA==", - "dependencies": { - "asynckit": "^0.4.0", - "combined-stream": "^1.0.6", - "mime-types": "^2.1.12" - }, - "engines": { - "node": ">= 0.12" - } - }, - "node_modules/@bitgo/sdk-coin-sui/node_modules/formidable": { - "version": "1.2.6", - "resolved": "https://registry.npmjs.org/formidable/-/formidable-1.2.6.tgz", - "integrity": "sha512-KcpbcpuLNOwrEjnbpMC0gS+X8ciDoZE1kkqzat4a8vrprf+s9pKNQ/QIwWfbfs4ltgmFl3MD177SNTkve3BwGQ==", - "deprecated": "Please upgrade to latest, formidable@v2 or formidable@v3! Check these notes: https://bit.ly/2ZEqIau", - "funding": { - "url": "https://ko-fi.com/tunnckoCore/commissions" - } - }, - "node_modules/@bitgo/sdk-coin-sui/node_modules/isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==" - }, - "node_modules/@bitgo/sdk-coin-sui/node_modules/mime": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", - "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==", - "bin": { - "mime": "cli.js" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/@bitgo/sdk-coin-sui/node_modules/readable-stream": { - "version": "2.3.8", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.8.tgz", - "integrity": "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==", - "dependencies": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - }, - "node_modules/@bitgo/sdk-coin-sui/node_modules/safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" - }, - "node_modules/@bitgo/sdk-coin-sui/node_modules/string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "dependencies": { - "safe-buffer": "~5.1.0" - } - }, - "node_modules/@bitgo/sdk-coin-sui/node_modules/superagent": { - "version": "3.8.2", - "resolved": "https://registry.npmjs.org/superagent/-/superagent-3.8.2.tgz", - "integrity": "sha512-gVH4QfYHcY3P0f/BZzavLreHW3T1v7hG9B+hpMQotGQqurOvhv87GcMCd6LWySmBuf+BDR44TQd0aISjVHLeNQ==", - "deprecated": "Please upgrade to v9.0.0+ as we have fixed a public vulnerability with formidable dependency. Note that v9.0.0+ requires Node.js v14.18.0+. See https://github.com/ladjs/superagent/pull/1800 for insight. This project is supported and maintained by the team at Forward Email @ https://forwardemail.net", - "dependencies": { - "component-emitter": "^1.2.0", - "cookiejar": "^2.1.0", - "debug": "^3.1.0", - "extend": "^3.0.0", - "form-data": "^2.3.1", - "formidable": "^1.1.1", - "methods": "^1.1.1", - "mime": "^1.4.1", - "qs": "^6.5.1", - "readable-stream": "^2.0.5" - }, - "engines": { - "node": ">= 4.0" - } - }, - "node_modules/@bitgo/sdk-coin-sui/node_modules/superstruct": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/superstruct/-/superstruct-1.0.4.tgz", - "integrity": "sha512-7JpaAoX2NGyoFlI9NBh66BQXGONc+uE+MRS5i2iOBKuS4e+ccgMDjATgZldkah+33DakBxDHiss9kvUcGAO8UQ==", - "engines": { - "node": ">=14.0.0" - } - }, "node_modules/@bitgo/sdk-coin-tia": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/@bitgo/sdk-coin-tia/-/sdk-coin-tia-3.0.4.tgz", diff --git a/package.json b/package.json index a6a3a09a..7c94bee2 100644 --- a/package.json +++ b/package.json @@ -9,9 +9,9 @@ } }, "dependencies": { + "@bitgo-beta/sdk-coin-sui": "^1.4.1-alpha.204", "@bitgo/abstract-cosmos": "11.0.4", "@bitgo/abstract-utxo": "8.14.1", - "@bitgo/sdk-opensslbytes": "^2.0.0", "@bitgo/sdk-api": "1.54.0", "@bitgo/sdk-coin-ada": "4.2.13", "@bitgo/sdk-coin-algo": "2.1.33", @@ -44,13 +44,13 @@ "@bitgo/sdk-coin-polygon": "21.0.4", "@bitgo/sdk-coin-sei": "3.0.4", "@bitgo/sdk-coin-sol": "4.5.1", - "@bitgo/sdk-coin-sui": "5.6.3", "@bitgo/sdk-coin-tia": "3.0.4", "@bitgo/sdk-coin-trx": "2.0.35", "@bitgo/sdk-coin-xlm": "3.2.9", "@bitgo/sdk-coin-xrp": "2.1.16", "@bitgo/sdk-coin-zec": "2.0.35", "@bitgo/sdk-coin-zeta": "3.0.4", + "@bitgo/sdk-opensslbytes": "^2.0.0", "@bitgo/utxo-lib": "10.3.0", "@ethereumjs/common": "2.6.5", "@lottiefiles/react-lottie-player": "3.4.9", diff --git a/src/containers/BuildUnsignedConsolidation/BuildUnsignedConsolidationCoin.tsx b/src/containers/BuildUnsignedConsolidation/BuildUnsignedConsolidationCoin.tsx index dce3dda9..a8e3dc98 100644 --- a/src/containers/BuildUnsignedConsolidation/BuildUnsignedConsolidationCoin.tsx +++ b/src/containers/BuildUnsignedConsolidation/BuildUnsignedConsolidationCoin.tsx @@ -9,13 +9,14 @@ import { import { TronForm } from '~/containers/BuildUnsignedConsolidation/TronForm'; import { TronTokenForm } from '~/containers/BuildUnsignedConsolidation/TronTokenForm'; import { CoinsSelectAutocomplete } from '~/components'; -import { buildUnsignedConsolidationCoins } from '~/helpers/config'; +import { buildUnsignedConsolidationCoins, tokenParentCoins } from '~/helpers/config'; import { BackToHomeHelperText } from '~/components/BackToHomeHelperText'; import { ConsolidationRecoveryBatch } from '@bitgo/sdk-coin-trx'; import { useAlertBanner } from '~/contexts'; import { GenericEcdsaForm } from '~/containers/BuildUnsignedConsolidation/GenericEcdsaForm'; import { SolForm } from '~/containers/BuildUnsignedConsolidation/SolForm'; import { SolTokenForm } from '~/containers/BuildUnsignedConsolidation/SolTokenForm'; +import { SuiTokenForm } from '~/containers/BuildUnsignedConsolidation/SuiTokenForm'; type ConsolidationFormProps = { coin?: string; @@ -25,10 +26,9 @@ type ConsolidationFormProps = { function isRecoveryConsolidationTransaction( result: any ): result is ConsolidationRecoveryBatch { - const consolidationRecoveryBatch = result as ConsolidationRecoveryBatch; return ( - consolidationRecoveryBatch && - consolidationRecoveryBatch.transactions !== undefined + ('txRequests' in result && !!result['txRequests']) || + ('transactions' in result && !!result['transactions']) ); } @@ -343,6 +343,59 @@ function ConsolidationForm({ coin, environment }: ConsolidationFormProps) { console.log(e); } + setSubmitting(false); + } + }} + /> + ); + case 'suiToken': + case 'tsuiToken': + return ( + { + setSubmitting(true); + try { + await window.commands.setBitGoEnvironment(environment); + const parentCoin = tokenParentCoins[coin]; + const chainData = await window.queries.getChain(parentCoin); + const consolidateData = await window.commands.recoverConsolidations(parentCoin, { + bitgoKey: values.bitgoKey.replace(/\s+/g, ''), + tokenContractAddress: values.packageId, + seed: values.seed, + }); + + if (consolidateData instanceof Error) { + throw consolidateData; + } + + const showSaveDialogData = await window.commands.showSaveDialog({ + filters: [ + { + name: 'Custom File Type', + extensions: ['json'], + }, + ], + defaultPath: `~/${chainData}-unsigned-consolidation-${Date.now()}.json`, + }); + if (!showSaveDialogData.filePath) { + throw new Error('No file path selected'); + } + + await window.commands.writeFile( + showSaveDialogData.filePath, + JSON.stringify(consolidateData, null, 2), + { encoding: 'utf8' } + ); + navigate( + `/${environment}/build-unsigned-consolidation/${coin}/success` + ); + } catch (e) { + if (e instanceof Error) { + setAlert(e.message); + } else { + console.log(e); + } + setSubmitting(false); } }} diff --git a/src/containers/BuildUnsignedConsolidation/SuiTokenForm.tsx b/src/containers/BuildUnsignedConsolidation/SuiTokenForm.tsx new file mode 100644 index 00000000..7fece572 --- /dev/null +++ b/src/containers/BuildUnsignedConsolidation/SuiTokenForm.tsx @@ -0,0 +1,136 @@ +import { Form, FormikHelpers, FormikProvider, useFormik } from 'formik'; +import { Link } from 'react-router-dom'; +import * as Yup from 'yup'; +import { + Button, + FormikPasswordfield, + FormikTextarea, + FormikTextfield, +} from '~/components'; + +const validationSchema = Yup.object({ + userKey: Yup.string(), + backupKey: Yup.string(), + bitgoKey: Yup.string().required(), + packageId: Yup.string().required(), + walletPassphrase: Yup.string(), + startingScanIndex: Yup.number(), + endingScanIndex: Yup.number().moreThan( + Yup.ref('startingScanIndex'), + 'Ending scan index must be greater than starting scan index' + ), + seed: Yup.string(), +}).required(); + +export type SuiFormValues = Yup.Asserts; + +export type SuiTokenFormValues = { + onSubmit: ( + values: SuiFormValues, + formikHelpers: FormikHelpers + ) => void | Promise; +}; + +export function SuiTokenForm({ onSubmit }: SuiTokenFormValues) { + const formik = useFormik({ + onSubmit, + initialValues: { + userKey: '', + backupKey: '', + bitgoKey: '', + packageId: '', + walletPassphrase: '', + startingScanIndex: 1, + endingScanIndex: 21, + seed: undefined, + }, + }); + + return ( + +
+

+ Self-managed cold or Hot wallet details +

+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ + +
+
+
+ ); +} diff --git a/src/containers/BuildUnsignedSweepCoin/BuildUnsignedSweepCoin.tsx b/src/containers/BuildUnsignedSweepCoin/BuildUnsignedSweepCoin.tsx index e01189d1..00da3d67 100644 --- a/src/containers/BuildUnsignedSweepCoin/BuildUnsignedSweepCoin.tsx +++ b/src/containers/BuildUnsignedSweepCoin/BuildUnsignedSweepCoin.tsx @@ -30,6 +30,7 @@ import { TronForm } from './TronForm'; import { TronTokenForm } from './TronTokenForm'; import { SolanaForm } from './SolanaForm'; import { SolanaTokenForm } from './SolanaTokenForm'; +import { SuiTokenForm } from './SuiTokenForm'; import { CardanoForm } from './CardanoForm'; import { BackToHomeHelperText } from '~/components/BackToHomeHelperText'; import { buildUnsignedSweepCoins, tokenParentCoins } from '~/helpers/config'; @@ -1179,6 +1180,73 @@ function Form() { { encoding: 'utf-8' } ); + navigate( + `/${bitGoEnvironment}/build-unsigned-sweep/${coin}/success` + ); + } catch (err) { + if (err instanceof Error) { + setAlert(err.message); + } else { + console.error(err); + } + setSubmitting(false); + } + }} + /> + ); + case 'suiToken': + case 'tsuiToken': + return ( + { + setAlert(undefined); + setSubmitting(true); + try { + await window.commands.setBitGoEnvironment(bitGoEnvironment, coin); + const parentCoin = tokenParentCoins[coin]; + const chainData = coin; + const recoverData = await window.commands.recover(parentCoin, { + bitgoKey: values.bitgoKey.replace(/\s+/g, ''), + tokenContractAddress: values.packageId, + recoveryDestination: values.recoveryDestination, + seed: values.seed, + ignoreAddressTypes: [], + userKey: '', + backupKey: '' + }); + assert( + isRecoveryTransaction(recoverData), + 'Fully-signed recovery transaction not detected.' + ); + + const showSaveDialogData = await window.commands.showSaveDialog({ + filters: [ + { + name: 'Custom File Type', + extensions: ['json'], + }, + ], + defaultPath: `~/${chainData}-unsigned-sweep-${Date.now()}.json`, + }); + + if (!showSaveDialogData.filePath) { + throw new Error('No file path selected'); + } + + await window.commands.writeFile( + showSaveDialogData.filePath, + JSON.stringify( + { + ...recoverData, + ...(await includePubsFor(coin, values)), + }, + null, + 2 + ), + { encoding: 'utf-8' } + ); + navigate( `/${bitGoEnvironment}/build-unsigned-sweep/${coin}/success` ); diff --git a/src/containers/BuildUnsignedSweepCoin/SuiTokenForm.tsx b/src/containers/BuildUnsignedSweepCoin/SuiTokenForm.tsx new file mode 100644 index 00000000..73edee89 --- /dev/null +++ b/src/containers/BuildUnsignedSweepCoin/SuiTokenForm.tsx @@ -0,0 +1,93 @@ +import { Form, FormikHelpers, FormikProvider, useFormik } from 'formik'; +import { Link } from 'react-router-dom'; +import * as Yup from 'yup'; +import { Button, FormikTextfield } from '~/components'; + +const validationSchema = Yup.object({ + userKey: Yup.string().required(), + backupKey: Yup.string().required(), + bitgoKey: Yup.string().required(), + packageId: Yup.string().required(), + recoveryDestination: Yup.string().required(), + seed: Yup.string(), +}).required(); + +type SuiFormValues = Yup.Asserts; + +export type SuiTokenFormProps = { + onSubmit: ( + values: SuiFormValues, + formikHelpers: FormikHelpers + ) => void | Promise; +}; + +export function SuiTokenForm({ onSubmit }: SuiTokenFormProps) { + const formik = useFormik({ + onSubmit, + initialValues: { + userKey: '', + backupKey: '', + bitgoKey: '', + packageId: '', + recoveryDestination: '', + seed: undefined, + }, + validationSchema, + }); + + return ( + +
+

+ Self-managed cold wallet details +

+
+ +
+
+ +
+
+ +
+
+ +
+
+ + +
+
+
+ ); +} diff --git a/src/containers/CreateBroadcastableTransaction/CreateBroadcastableTransactionIndex.tsx b/src/containers/CreateBroadcastableTransaction/CreateBroadcastableTransactionIndex.tsx index 49ef8060..2cbc416d 100644 --- a/src/containers/CreateBroadcastableTransaction/CreateBroadcastableTransactionIndex.tsx +++ b/src/containers/CreateBroadcastableTransaction/CreateBroadcastableTransactionIndex.tsx @@ -72,7 +72,8 @@ export function CreateBroadcastableTransactionIndex() { assert(isSignedTransaction(tx), 'Signed transaction not found'); - const coin = tx.signatureShares[0].txRequest.walletCoin; + let coin = tx.signatureShares[0].txRequest.walletCoin; + coin = (coin as string).split(':')[0]; const chainData = await window.queries.getChain(coin); // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment const broadcastTx: Error | BroadcastableSweepTransaction = diff --git a/src/containers/NonBitGoRecoveryCoin/NonBitGoRecoveryCoin.tsx b/src/containers/NonBitGoRecoveryCoin/NonBitGoRecoveryCoin.tsx index 45ba2632..24578b00 100644 --- a/src/containers/NonBitGoRecoveryCoin/NonBitGoRecoveryCoin.tsx +++ b/src/containers/NonBitGoRecoveryCoin/NonBitGoRecoveryCoin.tsx @@ -954,6 +954,8 @@ function Form() { ); case 'trxToken': case 'ttrxToken': + case 'suiToken': + case 'tsuiToken': return ( = { Icon: 'sui', value: 'sui', }, + suiToken: { + Title: 'SUI Token', + Description: 'Sui Token', + Icon: 'sui', + value: 'suiToken', + }, tsui: { Title: 'TSUI', Description: 'Testnet Sui', Icon: 'sui', value: 'tsui', }, + tsuiToken: { + Title: 'TSUI Token', + Description: 'Testnet Sui Token', + Icon: 'sui', + value: 'tsuiToken', + }, tbtc: { Title: 'TBTC', Description: 'Testnet Bitcoin', @@ -606,6 +618,7 @@ export const buildUnsignedConsolidationCoins: Record< allCoinMetas.sol, allCoinMetas.solToken, allCoinMetas.sui, + allCoinMetas.suiToken, ], test: [ allCoinMetas.ttrx, @@ -615,6 +628,7 @@ export const buildUnsignedConsolidationCoins: Record< allCoinMetas.tsol, allCoinMetas.tsolToken, allCoinMetas.tsui, + allCoinMetas.tsuiToken, ], }; @@ -656,6 +670,7 @@ export const buildUnsignedSweepCoins: Record< allCoinMetas.hbar, allCoinMetas.algo, allCoinMetas.sui, + allCoinMetas.suiToken, ] as const, test: [ allCoinMetas.tbtc, @@ -684,6 +699,7 @@ export const buildUnsignedSweepCoins: Record< allCoinMetas.talgo, allCoinMetas.tbsc, allCoinMetas.tsui, + allCoinMetas.tsuiToken, ] as const, }; @@ -733,6 +749,7 @@ export const nonBitgoRecoveryCoins: Record = allCoinMetas.hbar, allCoinMetas.algo, allCoinMetas.sui, + allCoinMetas.suiToken, ] as const, test: [ allCoinMetas.tbtc, @@ -771,6 +788,7 @@ export const nonBitgoRecoveryCoins: Record = allCoinMetas.thbar, allCoinMetas.talgo, allCoinMetas.tsui, + allCoinMetas.tsuiToken, ] as const, }; @@ -928,6 +946,10 @@ export const tokenParentCoins = { topethToken: 'topeth', polygonToken: 'polygon', tpolygonToken: 'tpolygon', + suiToken: 'sui', + tsuiToken: 'tsui', + trxToken: 'trx', + ttrxToken: 'ttrx' }; export type EvmCcrNonBitgoCoinConfigType = { diff --git a/src/utils/types.ts b/src/utils/types.ts index 4cbb9c43..400ebb52 100644 --- a/src/utils/types.ts +++ b/src/utils/types.ts @@ -7,7 +7,7 @@ import { } from '@bitgo/sdk-coin-trx'; import { Hbar, Thbar } from '@bitgo/sdk-coin-hbar'; import { Algo, Talgo } from '@bitgo/sdk-coin-algo'; -import { Sui, Tsui } from '@bitgo/sdk-coin-sui'; +import { Sui, Tsui } from '@bitgo-beta/sdk-coin-sui'; export type createAdaBroadcastableSweepTransactionParameters = | Parameters[0]