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

chore: update RPCs - starkNet_createAccount , starkNet_createAccountLegacy, starkNet_upgradeAccContract to handle new txn state #458

Merged
Changes from 1 commit
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
77f4b7b
feat: add stark scan client
stanleyyconsensys Sep 2, 2024
6b7a5e2
chore: add starkscan config
stanleyyconsensys Sep 2, 2024
3c9a523
chore: lint
stanleyyconsensys Sep 2, 2024
576f302
chore: add interface
stanleyyconsensys Sep 2, 2024
19fdf56
Merge branch 'main' into feat/add-stark-scan-client
stanleyyconsensys Sep 5, 2024
5d446cb
chore: support multiple txn
stanleyyconsensys Sep 5, 2024
3dbdf32
chore: update starkscan
stanleyyconsensys Sep 5, 2024
924ea45
chore: update stark scan client
stanleyyconsensys Sep 6, 2024
bcf34c7
chore: update contract func name
stanleyyconsensys Sep 6, 2024
d1ad70c
chore: fix test
stanleyyconsensys Sep 6, 2024
1a061d3
chore: update data client
stanleyyconsensys Sep 6, 2024
3bda85f
Merge branch 'main' into feat/add-stark-scan-client
stanleyyconsensys Sep 6, 2024
114ea6d
Merge branch 'main' into feat/add-stark-scan-client
stanleyyconsensys Oct 22, 2024
7539056
Merge branch 'main' into feat/add-stark-scan-client
stanleyyconsensys Dec 2, 2024
ed699ff
chore: re-structure starkscan type
stanleyyconsensys Dec 2, 2024
93adb36
chore: add test coverage
stanleyyconsensys Dec 2, 2024
dadb493
chore: factory and config
stanleyyconsensys Dec 2, 2024
b21a5d2
chore: add backward compatibility for transactions type
stanleyyconsensys Dec 2, 2024
07f0232
chore: add comment
stanleyyconsensys Dec 2, 2024
7a26c70
chore: lint
stanleyyconsensys Dec 2, 2024
804a2bd
chore: resolve review comment
stanleyyconsensys Dec 4, 2024
8e9e163
chore: change dataVersion to enum
stanleyyconsensys Dec 4, 2024
b09361f
chore: lint
stanleyyconsensys Dec 4, 2024
7cbd66f
chore: update test helper and refactor ContractAddressFilter
stanleyyconsensys Dec 5, 2024
f657422
chore: lint
stanleyyconsensys Dec 5, 2024
4ee01bc
chore: add test for dataVersion filter
stanleyyconsensys Dec 5, 2024
3a99e76
chore: update txn state mgr test
stanleyyconsensys Dec 5, 2024
38e5d63
chore: update search condition
stanleyyconsensys Dec 5, 2024
63e3030
chore: update starkscan to handle missing selector_name
stanleyyconsensys Dec 5, 2024
6391e81
Merge branch 'feat/add-stark-scan-client' into chore/refactor-txn-mgr
stanleyyconsensys Dec 5, 2024
873a1de
Merge branch 'main' into chore/refactor-txn-mgr
khanti42 Dec 5, 2024
97f0e05
Merge branch 'main' into chore/revamp-list-transactions
stanleyyconsensys Dec 5, 2024
956b10e
chore: apply starkscan for list transaction
stanleyyconsensys Dec 6, 2024
29f7c5f
chore: update list transactions handle
stanleyyconsensys Dec 6, 2024
103f087
Merge branch 'feat/refactor-list-transactions-with-starkscan' into ch…
stanleyyconsensys Dec 10, 2024
8b8d4b6
chore: refactor execute txn
stanleyyconsensys Dec 10, 2024
0ee7431
chore: refactor execute txn
stanleyyconsensys Dec 10, 2024
cf64931
chore: update create account and upgrade account
stanleyyconsensys Dec 10, 2024
12be249
chore: lint
stanleyyconsensys Dec 10, 2024
c5e7741
Revert "chore: lint"
stanleyyconsensys Dec 10, 2024
bb69ff5
Revert "chore: update create account and upgrade account"
stanleyyconsensys Dec 10, 2024
69aa0ec
chore: update rpcs to handle v2 data
stanleyyconsensys Dec 10, 2024
817e874
Merge branch 'feat/refactor-list-transactions-with-starkscan' into ch…
stanleyyconsensys Dec 10, 2024
ed1435c
Merge branch 'chore/update-execute-txn-with-new-txn-data' into chore/…
stanleyyconsensys Dec 10, 2024
c2ab083
chore: update rpcs to handle new txn state data
stanleyyconsensys Dec 10, 2024
fc22842
Merge branch 'feat/refactor-list-transactions-with-starkscan' into ch…
stanleyyconsensys Dec 11, 2024
3d0c529
chore: fix naming
stanleyyconsensys Dec 11, 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
Prev Previous commit
Next Next commit
chore: update rpcs to handle v2 data
stanleyyconsensys committed Dec 10, 2024
commit 69aa0ec629bcc7ac7a2a78bcd172bc971b3e7dbb
18 changes: 6 additions & 12 deletions packages/starknet-snap/src/createAccount.ts
Original file line number Diff line number Diff line change
@@ -26,6 +26,7 @@ import {
waitForTransaction,
estimateAccountDeployFee,
} from './utils/starknetUtils';
import { newDeployTransaction } from './utils/transaction';

/**
* Create an starknet account.
@@ -142,21 +143,14 @@ export async function createAccount(

await upsertAccount(userAccount, wallet, saveMutex);

const txn: Transaction = {
const txn = newDeployTransaction({
txnHash: deployResp.transaction_hash,
txnType: VoyagerTransactionType.DEPLOY_ACCOUNT,
chainId: network.chainId,
senderAddress: deployResp.contract_address,
contractAddress: deployResp.contract_address,
contractFuncName: '',
contractCallData: [],
finalityStatus: TransactionStatus.RECEIVED,
executionStatus: TransactionStatus.RECEIVED,
status: '',
failureReason: '',
eventIds: [],
timestamp: Math.floor(Date.now() / 1000),
};
// whenever create account is happen, we pay the fee in ETH, so txnVersion is 1
// FIXME: it should allow to pay the fee in STRK
txnVersion: 1,
});

await upsertTransaction(txn, wallet, saveMutex);
}
21 changes: 8 additions & 13 deletions packages/starknet-snap/src/upgradeAccContract.ts
Original file line number Diff line number Diff line change
@@ -23,6 +23,7 @@ import {
isAccountDeployed,
estimateFee,
} from './utils/starknetUtils';
import { newInvokeTransaction } from './utils/transaction';

/**
*
@@ -145,21 +146,15 @@ export async function upgradeAccContract(params: ApiParamsWithKeyDeriver) {
throw new Error(`Transaction hash is not found`);
}

const txn: Transaction = {
const txn = newInvokeTransaction({
txnHash: txnResp.transaction_hash,
txnType: VoyagerTransactionType.INVOKE,
chainId: network.chainId,
senderAddress: contractAddress,
contractAddress,
contractFuncName: 'upgrade',
contractCallData: CallData.compile(calldata),
finalityStatus: TransactionStatus.RECEIVED,
executionStatus: TransactionStatus.RECEIVED,
status: '', // DEPRECATED LATER
failureReason: '',
eventIds: [],
timestamp: Math.floor(Date.now() / 1000),
};
chainId: network.chainId,
maxFee: maxFee.toString(10),
calls: [txnInvocation],
// whenever upgrade is happen, we pay the fee in ETH, so txnVersion is 1
txnVersion: 1,
});

await upsertTransaction(txn, wallet, saveMutex);

31 changes: 0 additions & 31 deletions packages/starknet-snap/test/src/upgradeAccContract.test.ts
Original file line number Diff line number Diff line change
@@ -280,36 +280,5 @@ describe('Test function: upgradeAccContract', function () {
expect(result.message).to.be.include('Transaction hash is not found');
}
});

it('should save transaction when execute transaction success', async function () {
executeTxnStub.resolves(sendTransactionResp);
estimateFeeStub.resolves(estimateFeeResp);
walletStub.rpcStubs.snap_dialog.resolves(true);
const address = (
apiParams.requestParams as UpgradeTransactionRequestParams
).contractAddress;
const calldata = CallData.compile({
implementation: ACCOUNT_CLASS_HASH,
calldata: [0],
});
const txn = {
txnHash: sendTransactionResp.transaction_hash,
txnType: VoyagerTransactionType.INVOKE,
chainId: STARKNET_SEPOLIA_TESTNET_NETWORK.chainId,
senderAddress: address,
contractAddress: address,
contractFuncName: 'upgrade',
contractCallData: CallData.compile(calldata),
finalityStatus: TransactionStatus.RECEIVED,
executionStatus: TransactionStatus.RECEIVED,
status: '',
failureReason: '',
eventIds: [],
};

const result = await upgradeAccContract(apiParams);
expect(result).to.be.equal(sendTransactionResp);
expect(upsertTransactionStub).to.calledOnceWith(sinon.match(txn));
});
});
});