Skip to content

Commit

Permalink
Update version walletconnet to 2.11.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Thiendekaco committed Mar 2, 2024
1 parent c1d6cb3 commit bdc657a
Show file tree
Hide file tree
Showing 19 changed files with 200 additions and 2,580 deletions.
64 changes: 0 additions & 64 deletions packages/capsule/README.md

This file was deleted.

75 changes: 0 additions & 75 deletions packages/capsule/package.json

This file was deleted.

4 changes: 0 additions & 4 deletions packages/capsule/src/icon.ts

This file was deleted.

107 changes: 0 additions & 107 deletions packages/capsule/src/index.ts

This file was deleted.

17 changes: 0 additions & 17 deletions packages/capsule/src/types.ts

This file was deleted.

22 changes: 0 additions & 22 deletions packages/capsule/tsconfig.json

This file was deleted.

2 changes: 1 addition & 1 deletion packages/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
},
"dependencies": {
"@polkadot/extension-inject": "^0.46.5",
"@walletconnect/universal-provider": "^2.11.0",
"@walletconnect/universal-provider": "^2.11.2",
"bignumber.js": "^9.1.0",
"ethers": "5.5.4",
"joi": "17.9.1"
Expand Down
17 changes: 11 additions & 6 deletions packages/demo/src/utils/api/substrateApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,26 @@ export class substrateApi {
public async getMaxTransfer (amount: string, senderAddress: string, recipientAddress: string) {
if(!this.api || !this.api.isReady ) return '0';

const transferExtrinsic = this.api.tx.balances.transferKeepAlive(recipientAddress, amount)
const balances = await this.api.derive.balances?.all(senderAddress)
const maxTransfer = balances.availableBalance

return maxTransfer.toString();
}

public async isAvailableAmount ( amount: string, senderAddress: string, recipientAddress: string ) {

const transferExtrinsic = this.api.tx.balances.transferKeepAlive(recipientAddress, amount)
const [ { partialFee }, balances ] = await Promise.all([
transferExtrinsic.paymentInfo(senderAddress),
this.api.derive.balances?.all(senderAddress)
this.getMaxTransfer(amount, senderAddress, recipientAddress)
])

const adjFee = partialFee.muln(110).div(BN_HUNDRED);
const maxTransfer = balances.availableBalance.sub(adjFee);

return maxTransfer.toString();
}
const maxTransfer = (new BN(balances)).sub(adjFee);

public async isAvailableAmount ( amount: string, senderAddress: string, recipientAddress: string ) {

const maxTransfer = new BN( await this.getMaxTransfer(amount, senderAddress, recipientAddress));
return !!(maxTransfer.gt(new BN(this.api?.consts.balances.existentialDeposit as any)) && maxTransfer.gt(new BN(amount)))
}

Expand Down
8 changes: 4 additions & 4 deletions packages/demo/src/web3-onboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const injected = injectedModule({


const walletConnectPolkadot = walletConnectPolkadotModule({
projectId: '762e91498a11e0acc664cdd0fd2af181',
projectId: '59b5826141a56b204e9e0a3f7e46641d',
dappUrl: 'https://w3o-demo.subwallet.app/'
})
const metamaskSDKWallet = metamaskSDK({
Expand All @@ -52,9 +52,9 @@ const polkadotWallet = polkadot_jsModule();
const subwalletPolkadotWalet = subwalletPolkadotModule();
const talismanWallet = talismanModule();
const polkadotVaultWallet = polkadotVaultModule();
const ledger = ledgerModule({ projectId : '762e91498a11e0acc664cdd0fd2af181', walletConnectVersion: 2 })
const ledger = ledgerModule({ projectId : '59b5826141a56b204e9e0a3f7e46641d', walletConnectVersion: 2 })
const walletConnect = walletConnectModule({
projectId: '762e91498a11e0acc664cdd0fd2af181',
projectId: '59b5826141a56b204e9e0a3f7e46641d',
dappUrl: 'https://w3o-demo.subwallet.app/'
})

Expand All @@ -72,7 +72,7 @@ export default init({
enabled: false
}
},
projectId : '762e91498a11e0acc664cdd0fd2af181',
projectId : '59b5826141a56b204e9e0a3f7e46641d',

// An array of wallet modules that you would like to be presented to the user to select from when connecting a wallet.
wallets: [
Expand Down
3 changes: 1 addition & 2 deletions packages/ledger/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@
"@ethersproject/providers": "5.5.0",
"@ledgerhq/connect-kit-loader": "^1.1.0",
"@subwallet-connect/common": "^1.0.1",
"@walletconnect/client": "^1.8.0",
"@walletconnect/ethereum-provider": "2.11.0",
"@walletconnect/ethereum-provider": "^2.11.2",
"@walletconnect/modal": "^2.6.2",
"rxjs": "^7.5.2"
},
Expand Down
6 changes: 1 addition & 5 deletions packages/ledger/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { WalletInit } from '@subwallet-connect/common'
import v1 from './v1.js'
import v2 from './v2.js'

export type LedgerOptionsWCv1 = {
Expand Down Expand Up @@ -50,10 +49,7 @@ export const isHexString = (value: string | number) => {
}

function ledger(options?: LedgerOptions): WalletInit {
const walletConnectVersion = options?.walletConnectVersion || 2
return walletConnectVersion === 1
? v1(options as LedgerOptionsWCv1)
: v2(options as LedgerOptionsWCv2)
return v2(options as LedgerOptionsWCv2)
}

export default ledger
Loading

0 comments on commit bdc657a

Please sign in to comment.