Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing CA #3544

Open
wants to merge 37 commits into
base: webapp-dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
e028c32
adding klaster sdk
nampc1 Sep 4, 2024
81a9977
adding klaster sdk
nampc1 Sep 5, 2024
fbb37e4
Handle create SA instead EOA account when injecting from wallet
S2kael Sep 5, 2024
94a2df5
test klaster sdk
nampc1 Sep 6, 2024
ae172ac
test particle sdk
S2kael Sep 6, 2024
2356e0c
support klaster
nampc1 Sep 7, 2024
948be5d
fix bug for klaster
nampc1 Sep 7, 2024
084a061
Refactor and fix some error
S2kael Sep 7, 2024
fa25601
fix bug for klaster
nampc1 Sep 8, 2024
5b1802b
Merge branch 'webapp-ca' of https://github.com/Koniverse/SubWallet-Ex…
S2kael Sep 9, 2024
b95672e
swap with uniswap
nampc1 Sep 10, 2024
b3a9f7d
update swap with ca
nampc1 Sep 11, 2024
ccf51cf
Update auto-build
saltict Sep 11, 2024
7ee1166
refactor across bridge
nampc1 Sep 12, 2024
1cb0874
update particle
nampc1 Sep 12, 2024
bb18168
[Issue-3596] Update UI for Chain abstraction demo
dungnguyen-art Sep 13, 2024
c928d01
[Issue-3596] Update animation when hover
dungnguyen-art Sep 12, 2024
5c7cf2b
Merge remote-tracking branch 'origin/koni/dev/issue-3596' into webapp-ca
nampc1 Sep 13, 2024
b96a3be
[Issue-3596] Update default provider and bridge
dungnguyen-art Sep 13, 2024
7279f9a
Merge remote-tracking branch 'origin/koni/dev/issue-3596' into webapp-ca
nampc1 Sep 13, 2024
9901358
refactor
nampc1 Sep 14, 2024
c754538
Handle transaction history
S2kael Sep 14, 2024
d20828f
update header UI
nampc1 Sep 14, 2024
ae66c20
[History] Show provider and change explorer url
S2kael Sep 14, 2024
406d935
update swap with Particle
nampc1 Sep 14, 2024
b7a12a0
Update production branch for webapp-ca on cloudflare pages
saltict Sep 16, 2024
3a5e2fa
Merge remote-tracking branch 'origin/webapp' into webapp-ca
S2kael Oct 2, 2024
7b358ed
[CA] Add more asset ref and add UX change CA provider
S2kael Oct 2, 2024
26a3ed3
[CA] Update UX
S2kael Oct 3, 2024
9614d94
[CA] Remove unused arg
S2kael Oct 4, 2024
f117e7d
[CA] Add swap pair `arbitrum_one - USDT --- base_mainnet - USDC`
S2kael Oct 8, 2024
06de88f
[CA] Add swap pair `arbitrum_one - USDC --- optimism - DAI`
S2kael Oct 8, 2024
d6373e1
[CA] Adjust fee for pair USDC-DAI
S2kael Oct 8, 2024
3a79961
[CA] Add swap pair `base - USDC --- optimism - DAI`
S2kael Oct 9, 2024
cafe986
[CA] Fix cannot swap with Particle
S2kael Oct 10, 2024
8ac56ac
[CA] Support transfer on chain
S2kael Oct 12, 2024
b90250f
[CA] Fix error with uniswap
S2kael Oct 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/push-webapp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
- webapp
- webapp-dev
- webapp-demo
- webapp-ca

jobs:
master:
Expand Down Expand Up @@ -45,9 +46,9 @@ jobs:
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: ${{ vars.CLOUDFLARE_PAGES_PROJECT_NAME }}
projectName: ${{ github.ref_name == 'webapp-ca' && 'chain-abstraction' || vars.CLOUDFLARE_PAGES_PROJECT_NAME }}
gitHubToken: ${{ secrets.GH_AUTOMATION_TOKEN }}
branch: ${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.number) || github.ref_name }}
branch: ${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.number) || github.ref_name }} # Branch webapp & webapp-ca will be production branch
directory: './packages/webapp/build'
wranglerVersion: '3'
- if: "github.ref_name == 'webapp-dev' && github.event_name == 'push'"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ Cronjob is define in folder `packages/extension-koni-base/src/cron`.
### Add new redux store
- Subwallet extension use [redux-tookit](https://redux-toolkit.js.org/) to generate store.
- Define redux store reducers and state into separate file by method `createSlice` of redux toolkit.
- Map reducer into root store in file index.ts
- Map reducer into root store in file klaster.ts

### Add new message caller
Read "Add a message handle"
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@
"@polkadot/types-support": "^12.0.2",
"@polkadot/util": "^12.6.2",
"@polkadot/util-crypto": "^12.6.2",
"@subwallet/chain-list": "0.2.87",
"@uniswap/v3-periphery": "1.4.4",
"@subwallet/chain-list": "0.2.89-beta.5",
"@subwallet/keyring": "^0.1.6",
"@subwallet/react-ui": "5.1.2-b79",
"@subwallet/ui-keyring": "^0.1.6",
Expand Down
8 changes: 7 additions & 1 deletion packages/extension-base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"@metamask/safe-event-emitter": "^2.0.0",
"@metaverse-network-sdk/type-definitions": "^0.0.1-13",
"@oak-foundation/types": "^0.0.23",
"@particle-network/aa": "^2.0.2",
"@polkadot-api/merkleize-metadata": "^1.1.0",
"@polkadot/api": "^11.0.3",
"@polkadot/api-base": "^10.11.2",
Expand All @@ -55,13 +56,16 @@
"@reduxjs/toolkit": "^1.9.1",
"@sora-substrate/type-definitions": "^1.17.7",
"@substrate/connect": "^0.8.9",
"@subwallet/chain-list": "0.2.87",
"@subwallet/chain-list": "0.2.89-beta.5",
"@subwallet/extension-base": "^1.2.30-0",
"@subwallet/extension-chains": "^1.2.30-0",
"@subwallet/extension-dapp": "^1.2.30-0",
"@subwallet/extension-inject": "^1.2.30-0",
"@subwallet/keyring": "^0.1.6",
"@subwallet/ui-keyring": "^0.1.6",
"@uniswap/sdk-core": "^5.3.1",
"@uniswap/v3-periphery": "^1.4.4",
"@uniswap/v3-sdk": "^3.13.1",
"@walletconnect/keyvaluestorage": "^1.1.1",
"@walletconnect/sign-client": "^2.14.0",
"@walletconnect/types": "^2.14.0",
Expand All @@ -85,12 +89,14 @@
"is-buffer": "^2.0.5",
"joi": "^17.13.3",
"json-rpc-engine": "^6.1.0",
"klaster-sdk": "^0.5.11",
"manta-extension-sdk": "^1.1.0",
"moment": "^2.29.4",
"protobufjs": "^7.2.4",
"rxjs": "^7.8.1",
"sails-js": "^0.1.6",
"uuid": "^9.0.0",
"viem": "^2.21.2",
"web3": "^1.10.0",
"web3-core": "^1.10.0",
"web3-core-helpers": "^1.10.0",
Expand Down
11 changes: 10 additions & 1 deletion packages/extension-base/src/background/KoniTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { TransactionError } from '@subwallet/extension-base/background/errors/Tr
import { AuthUrls, Resolver } from '@subwallet/extension-base/background/handlers/State';
import { AccountAuthType, AccountJson, AddressJson, AuthorizeRequest, ConfirmationRequestBase, RequestAccountList, RequestAccountSubscribe, RequestAccountUnsubscribe, RequestAuthorizeCancel, RequestAuthorizeReject, RequestAuthorizeSubscribe, RequestAuthorizeTab, RequestCurrentAccountAddress, ResponseAuthorizeList, ResponseJsonGetAccountInfo, SeedLengths } from '@subwallet/extension-base/background/types';
import { RequestOptimalTransferProcess } from '@subwallet/extension-base/services/balance-service/helpers';
import { BridgeProvider, CAProvider } from '@subwallet/extension-base/services/chain-abstraction-service/helper/util';
import { _CHAIN_VALIDATION_ERROR } from '@subwallet/extension-base/services/chain-service/handler/types';
import { _ChainState, _EvmApi, _NetworkUpsertParams, _SubstrateApi, _ValidateCustomAssetRequest, _ValidateCustomAssetResponse, EnableChainParams, EnableMultiChainParams } from '@subwallet/extension-base/services/chain-service/types';
import { AppBannerData, AppConfirmationData, AppPopupData } from '@subwallet/extension-base/services/mkt-campaign-service/types';
Expand Down Expand Up @@ -445,7 +446,7 @@ export interface UiSettings {
unlockType: WalletUnlockType;
enableChainPatrol: boolean;
// On-ramp service account reference
walletReference: string;
walletReference: string
}

export type RequestSettingsType = UiSettings;
Expand Down Expand Up @@ -708,6 +709,7 @@ export interface TransactionHistoryItem<ET extends ExtrinsicType = ExtrinsicType
additionalInfo?: any,
startBlock?: number,
nonce?: number,
caProvider?: CAProvider
}

export interface SWError extends Error {
Expand Down Expand Up @@ -1879,6 +1881,11 @@ export interface PassPhishing {
pass: boolean;
}

export interface CaSetting {
caProvider: CAProvider,
bridgeProvider: BridgeProvider
}

export interface RequestPassPhishingPage {
url: string;
}
Expand Down Expand Up @@ -2448,6 +2455,8 @@ export interface KoniRequestSignatures {
/* Ledger */

'pri(ledger.generic.allow)': [null, string[], string[]];
'pri(ca.setConfig)': [CaSetting, null];
'pri(ca.getConfig)': [null, CaSetting];
}

export interface ApplicationMetadataType {
Expand Down
19 changes: 19 additions & 0 deletions packages/extension-base/src/background/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import type { SignerPayloadJSON, SignerPayloadRaw } from '@polkadot/types/types'
import type { HexString } from '@polkadot/util/types';
import type { KeypairType } from '@polkadot/util-crypto/types';

import { AccountContract } from '@particle-network/aa';
import { CurrentNetworkInfo, KoniRequestSignatures, NetworkJson } from '@subwallet/extension-base/background/KoniTypes';

import { TypeRegistry } from '@polkadot/types';
Expand Down Expand Up @@ -97,6 +98,24 @@ export interface AccountJson extends AbstractAddressJson {
source?: string;
/** Derivate path */
suri?: string;

/** Account abstraction */

/** Is smart account */
isSmartAccount?: boolean;
/** Smart account owner */
smartAccountOwner?: string;
/** AA sdk */
aaSdk?: 'particle' | 'klaster';
/** AA provider */
aaProvider?: AccountContract;

/** Account abstraction */
}

export interface SmartAccountData {
owner: string;
provider?: AccountContract;
}

export interface AddressJson extends AbstractAddressJson {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,12 @@ export async function getERC20SpendingApprovalTx (spender: _Address, owner: _Add
maxPriorityFeePerGas: priority.maxPriorityFeePerGas?.toString()
} as TransactionConfig;
}

export function encodeSpendingApproval (spender: _Address, owner: _Address, contractAddress: _Address, evmApi: _EvmApi, amount = '115792089237316195423570985008687907853269984665640564039457584007913129639935'): string {
const tokenContract = getERC20Contract(contractAddress, evmApi);
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
const approveCall = tokenContract.methods.approve(spender, amount); // TODO: need test

// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
return approveCall.encodeABI() as string;
}
Loading
Loading