diff --git a/packages/extension-base/src/core/logic-validation/transfer.ts b/packages/extension-base/src/core/logic-validation/transfer.ts index 11fa5e5734..025e069d32 100644 --- a/packages/extension-base/src/core/logic-validation/transfer.ts +++ b/packages/extension-base/src/core/logic-validation/transfer.ts @@ -8,20 +8,13 @@ import { TransactionWarning } from '@subwallet/extension-base/background/warning import { LEDGER_SIGNING_COMPATIBLE_MAP, SIGNING_COMPATIBLE_MAP, XCM_MIN_AMOUNT_RATIO } from '@subwallet/extension-base/constants'; import { _canAccountBeReaped } from '@subwallet/extension-base/core/substrate/system-pallet'; import { FrameSystemAccountInfo } from '@subwallet/extension-base/core/substrate/types'; -import { - _isCIP26Token, - getCardanoAssetId -} from '@subwallet/extension-base/services/balance-service/helpers/subscribe/cardano/utils'; +import { _isCIP26Token, getCardanoAssetId } from '@subwallet/extension-base/services/balance-service/helpers/subscribe/cardano/utils'; import { isBounceableAddress } from '@subwallet/extension-base/services/balance-service/helpers/subscribe/ton/utils'; import { _TRANSFER_CHAIN_GROUP } from '@subwallet/extension-base/services/chain-service/constants'; import { _EvmApi, _TonApi } from '@subwallet/extension-base/services/chain-service/types'; import { _getChainExistentialDeposit, _getChainNativeTokenBasicInfo, _getContractAddressOfToken, _getTokenMinAmount, _isNativeToken, _isTokenEvmSmartContract, _isTokenTonSmartContract } from '@subwallet/extension-base/services/chain-service/utils'; import { calculateGasFeeParams } from '@subwallet/extension-base/services/fee-service/utils'; -import { - isCardanoTransaction, - isSubstrateTransaction, - isTonTransaction -} from '@subwallet/extension-base/services/transaction-service/helpers'; +import { isCardanoTransaction, isSubstrateTransaction, isTonTransaction } from '@subwallet/extension-base/services/transaction-service/helpers'; import { OptionalSWTransaction, SWTransactionInput, SWTransactionResponse } from '@subwallet/extension-base/services/transaction-service/types'; import { AccountSignMode, BasicTxErrorType, BasicTxWarningCode, TransferTxErrorType } from '@subwallet/extension-base/types'; import { balanceFormatter, formatNumber, pairToAccount } from '@subwallet/extension-base/utils'; diff --git a/packages/extension-base/src/services/balance-service/transfer/cardano-transfer.ts b/packages/extension-base/src/services/balance-service/transfer/cardano-transfer.ts index 92d31f77ba..873235ab9e 100644 --- a/packages/extension-base/src/services/balance-service/transfer/cardano-transfer.ts +++ b/packages/extension-base/src/services/balance-service/transfer/cardano-transfer.ts @@ -2,13 +2,9 @@ // SPDX-License-Identifier: Apache-2.0 // todo: interface CardanoTransactionProps -import { _AssetType, _ChainAsset } from '@subwallet/chain-list/types'; -import { - _isCIP26Token, - estimateCardanoTxFee -} from '@subwallet/extension-base/services/balance-service/helpers/subscribe/cardano/utils'; +import { _ChainAsset } from '@subwallet/chain-list/types'; +import { estimateCardanoTxFee } from '@subwallet/extension-base/services/balance-service/helpers/subscribe/cardano/utils'; import { _CardanoApi } from '@subwallet/extension-base/services/chain-service/types'; -import { _isNativeToken } from '@subwallet/extension-base/services/chain-service/utils'; interface CardanoTransactionConfigProps { tokenInfo: _ChainAsset; @@ -30,37 +26,24 @@ export interface CardanoTransactionConfig { cardanoPayload: string // hex unsigned tx } -export async function createCardanoTransaction (params: CardanoTransactionConfigProps): Promise<[CardanoTransactionConfig | null, string]> { - const { tokenInfo, value } = params; - let tx: CardanoTransactionConfig | null = null; - - if (_isNativeToken(tokenInfo)) { - tx = await createTransferTransaction(params, _AssetType.NATIVE); - } - - if (_isCIP26Token(tokenInfo)) { - tx = await createTransferTransaction(params, _AssetType.CIP26); - } - - return [tx, value]; -} - // todo: await built tx, use assetType to check // eslint-disable-next-line @typescript-eslint/require-await -async function createTransferTransaction (params: CardanoTransactionConfigProps, assetType: _AssetType.NATIVE | _AssetType.CIP26): Promise { - // todo: payload must be string, if no payload => '' - const payload = '84a300d9010281825820561b6403b7836d69a7ef7c728f25425fbf27c17b76d5461361c3208caef5fdf601018282583900ad2b3ac4e3017adfb3cbb04c5ca7a678204daaac96accab6690010dc7ab98b3e995e211b8615b2466d3a93ec069e9d60f17cd1ef3434ea541a08f0d18082583900e33b8297e1ce697e07b12de2bc781280bac7b9c949c6194894e9b82132761cf8ea1eeb6628a4fc4fcf4470d6b8a38632a298d84f0c5b63c01b000000015084291b021a0002922da0f5f6'; - const fee = estimateCardanoTxFee(payload); +export async function createCardanoTransaction (params: CardanoTransactionConfigProps): Promise<[CardanoTransactionConfig | null, string]> { + const { from, networkKey, to, transferAll, value } = params; - console.log('fee', fee); + // const payload = await getPayload(sender, receiver, amount, policyId) || '' + const payload = '84a300d9010281825820125c1c772a98554b237fa63342f8cb0dde0e2a213c9180848efb2a9156a748ec01018282583900ad2b3ac4e3017adfb3cbb04c5ca7a678204daaac96accab6690010dc7ab98b3e995e211b8615b2466d3a93ec069e9d60f17cd1ef3434ea54821a0012dfeaa1581c3d64987c567150b011edeed959cd1293432b7f2bc228982e2be395f7a1530014df10426c7565646f742043617264616e6f1b00013e52b9abe00082583900e33b8297e1ce697e07b12de2bc781280bac7b9c949c6194894e9b82132761cf8ea1eeb6628a4fc4fcf4470d6b8a38632a298d84f0c5b63c0821b000000014f9b08c8a1581c3d64987c567150b011edeed959cd1293432b7f2bc228982e2be395f7a1530014df10426c7565646f742043617264616e6f1b0ddf7860dbd67d00021a0002a6cda0f5f6'; + const fee = estimateCardanoTxFee(payload); - return { - from: params.from, - to: params.to, - networkKey: params.networkKey, - value: params.value, - transferAll: params.transferAll, + const tx: CardanoTransactionConfig = { + from, + to, + networkKey, + value, + transferAll, estimateCardanoFee: fee, cardanoPayload: payload }; + + return [tx, value]; } diff --git a/packages/extension-koni-ui/src/Popup/Transaction/variants/SendFund.tsx b/packages/extension-koni-ui/src/Popup/Transaction/variants/SendFund.tsx index 704566fa16..42c12d8cc0 100644 --- a/packages/extension-koni-ui/src/Popup/Transaction/variants/SendFund.tsx +++ b/packages/extension-koni-ui/src/Popup/Transaction/variants/SendFund.tsx @@ -814,10 +814,12 @@ const Component = ({ className = '', isAllAccount, targetAccountProxy }: Compone useEffect(() => { // alibaba makeTransfer({ from: 'addr_test1qr3nhq5hu88xjls8kyk790rcz2qt43aee9yuvx2gjn5msgfjwcw036s7adnz3f8ufl85guxkhz3cvv4znrvy7rzmv0qquff93j', - networkKey: 'cardano_preproduction', + networkKey: 'cardano_testnet', to: 'addr_test1qzkjkwkyuvqh4hanewcych985euzqnd24jt2ej4kdyqpphr6hx9nax27yydcv9djgekn4ylvq60f6c830ng77dp5af2qrphdqh', - tokenSlug: 'cardano_preproduction-NATIVE-tADA', - value: '150000000', + // tokenSlug: 'cardano_testnet-NATIVE-tADA', + // value: '150000000', + tokenSlug: 'cardano_testnet-CIP26-BLUEDOT', + value: '350000000000000', transferAll: false }) .then((rs) => { diff --git a/yarn.lock b/yarn.lock index 021f34847b..0a58c283e6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6280,13 +6280,13 @@ __metadata: linkType: hard "@subwallet/chain-list@file:../SubWallet-Chainlist/packages/chain-list/build/::locator=root-workspace-0b6124%40workspace%3A.": - version: 0.2.91 - resolution: "@subwallet/chain-list@file:../SubWallet-Chainlist/packages/chain-list/build/#../SubWallet-Chainlist/packages/chain-list/build/::hash=109cff&locator=root-workspace-0b6124%40workspace%3A." + version: 0.2.94-beta.0 + resolution: "@subwallet/chain-list@file:../SubWallet-Chainlist/packages/chain-list/build/#../SubWallet-Chainlist/packages/chain-list/build/::hash=6e711e&locator=root-workspace-0b6124%40workspace%3A." dependencies: "@polkadot/dev": 0.67.167 "@polkadot/util": ^12.5.1 eventemitter3: ^5.0.1 - checksum: 9b6770320833b872c092ea4bbdf767774e75dca9640bb27e67306a4518cb9226b9b4ab768cefada0aa1231303ed6d684b5b6b944221ad5658e1fd27d7841e518 + checksum: c2a22f5fdcddb82cdd68c4408f169b8531c6fa54285a72ea1d40d6443eaae5221394a740573e81b315cac8fdd2093e82b51298ecc4788c12cddb944f1d2702d4 languageName: node linkType: hard @@ -6681,7 +6681,7 @@ __metadata: "@subwallet/keyring@file:../SubWallet-Base/packages/keyring/build/::locator=root-workspace-0b6124%40workspace%3A.": version: 0.1.7 - resolution: "@subwallet/keyring@file:../SubWallet-Base/packages/keyring/build/#../SubWallet-Base/packages/keyring/build/::hash=76926d&locator=root-workspace-0b6124%40workspace%3A." + resolution: "@subwallet/keyring@file:../SubWallet-Base/packages/keyring/build/#../SubWallet-Base/packages/keyring/build/::hash=7e8191&locator=root-workspace-0b6124%40workspace%3A." dependencies: "@emurgo/cardano-serialization-lib-nodejs": ^13.2.0 "@ethereumjs/tx": ^5.0.0 @@ -6702,7 +6702,7 @@ __metadata: rxjs: ^7.5.6 tiny-secp256k1: ^2.2.3 tslib: ^2.6.2 - checksum: e3f787399e9fd27f9261caeb41fb0b8f6e32fbff9e27dc5e51d4a9250ab432f78c95ef6f2ff1f335992b89250f4e9798623a158360e248853a02411b5fce303d + checksum: 6632f7a1814400cd2f472aa0daad091a95bcc5faddf3caace0e7b958ad6daedb53b523463d2b2f3a92711e531fdc7c8c259e1b2d676905a72464111c28b53b07 languageName: node linkType: hard @@ -6786,7 +6786,7 @@ __metadata: "@subwallet/ui-keyring@file:../SubWallet-Base/packages/ui-keyring/build/::locator=root-workspace-0b6124%40workspace%3A.": version: 0.1.7 - resolution: "@subwallet/ui-keyring@file:../SubWallet-Base/packages/ui-keyring/build/#../SubWallet-Base/packages/ui-keyring/build/::hash=8a079e&locator=root-workspace-0b6124%40workspace%3A." + resolution: "@subwallet/ui-keyring@file:../SubWallet-Base/packages/ui-keyring/build/#../SubWallet-Base/packages/ui-keyring/build/::hash=c748eb&locator=root-workspace-0b6124%40workspace%3A." dependencies: "@babel/runtime": ^7.20.1 "@polkadot/ui-settings": 2.9.14 @@ -6796,7 +6796,7 @@ __metadata: mkdirp: ^1.0.4 rxjs: ^7.5.7 store: ^2.0.12 - checksum: 7feda4950fd17a4d1726fa0f0b29c5893589e5014b122eeb5233149a04bd0175ee228c4ed43dea36e5be2ad125be6ff603bbecaa27316bae5549cb42a6a37673 + checksum: 9182a2be4292b35a9925ef7316b5af1c498fc9ac6e5855d43f34d77d8bf8cbc9b45e652308778a31c56abeacd9cfb06d58f10daa8ab455ede6c721d897e3efb9 languageName: node linkType: hard