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

feat: show upgrade dialog on get-starknet calls #247

Merged
merged 67 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
9fe75f1
feat: change account contract to cairo 1 (#152)
stanleyyconsensys Oct 4, 2023
1db6955
feat: sf-542 block cairo0 (#153)
stanleyyconsensys Oct 5, 2023
42a1f90
chore(deps): bump word-wrap from 1.2.3 to 1.2.5 (#131)
dependabot[bot] Oct 5, 2023
1a32b29
chore(deps): bump @adobe/css-tools from 4.2.0 to 4.3.1 (#132)
dependabot[bot] Oct 5, 2023
be880ca
chore(deps): bump semver from 7.3.8 to 7.5.2 (#130)
dependabot[bot] Oct 5, 2023
101804d
Merge branch 'main' into releases/2.3.0
stanleyyconsensys Oct 13, 2023
62f589e
feat: merge main
stanleyyconsensys Nov 17, 2023
2ee8e1b
feat: simplify snap logic
stanleyyconsensys Nov 17, 2023
ba81932
Merge branch 'main' into releases/2.3.0
stanleyyconsensys Nov 21, 2023
b87e23d
fix: replace hardcode class hash
stanleyyconsensys Nov 21, 2023
ef4eb37
fix: get version function
stanleyyconsensys Nov 21, 2023
bd45f53
fix: recover account for getting upgraded cairo 1 address
stanleyyconsensys Nov 21, 2023
c166dde
feat: sf 549 update all method to support upgraded address (#188)
stanleyyconsensys Jan 5, 2024
eb5f4d7
feat: sf-540 add account contract upgrade api (#189)
stanleyyconsensys Feb 21, 2024
34a11a4
Merge branch 'main' into releases/2.3.0
stanleyyconsensys Feb 28, 2024
c9270ac
feat: sf-539 UI upgrade account (#191)
stanleyyconsensys Feb 28, 2024
b0c4817
fix: test (#203)
stanleyyconsensys Feb 28, 2024
e84dd4e
Merge branch 'main' into releases/2.3.0
stanleyyconsensys Mar 22, 2024
c8276d0
chore: rebase
stanleyyconsensys Mar 22, 2024
065cc40
Merge branch 'main' into releases/2.3.0
stanleyyconsensys Apr 10, 2024
213b2e2
chore: update conflict
stanleyyconsensys Apr 10, 2024
63e405a
fix: lint issue
stanleyyconsensys Apr 11, 2024
e2b1039
feat: add webpack.config.dev.js for local serving of remoteEntry.js
khanti42 May 23, 2024
3c8ccf3
chore: lint and optional env variable for SNAP_ID
khanti42 May 24, 2024
e664d9e
fix: update get-starknet/webpack-dev-server dep to address security v…
khanti42 May 24, 2024
46414e7
fix: remoteEntry.js serving done on static file from dist/webpack folder
khanti42 May 24, 2024
14129eb
chore: added .env.sample example file
khanti42 May 24, 2024
cae8a9d
feat: optional PUBLIC_PATH env variable to produce local remoteEntry.js
khanti42 May 24, 2024
03eee4c
chore: updated README.md
khanti42 May 24, 2024
a776b04
Merge branch 'main' into feat/sf-614-rebase
stanleyyconsensys Jun 3, 2024
1a42322
fix: methods signature
khanti42 Jun 3, 2024
6f97ce1
test: make existing tests pass successfully
khanti42 Jun 3, 2024
ec49b03
fix: rollback check CairoVersion not needed
khanti42 Jun 3, 2024
de5a79f
fix: lint
khanti42 Jun 3, 2024
9bdc735
fix: contractCallData format in massagedTransaction
khanti42 Jun 3, 2024
63ca289
fix: upgrade function detection in getMassagedTransactions filtering …
khanti42 Jun 4, 2024
002fcb5
Merge branch 'feat/local-remoteentry-for-dev' into feat/sf-614-rebase
khanti42 Jun 4, 2024
d6f0111
refactor: ugrade detection mechanism similar to transfer based on met…
khanti42 Jun 5, 2024
0f68c85
test: adapt constants.test.ts
khanti42 Jun 5, 2024
e607658
feat: show upgrade dialog on get-starknet calls
khanti42 Jun 5, 2024
29f7a29
feat: sf 614 rebase (#246)
stanleyyconsensys Jun 6, 2024
556e9d7
Merge branch 'releases/2.3.0' into feat/sf-618
stanleyyconsensys Jun 6, 2024
47de7df
chore: upgrade modal link
khanti42 Jun 6, 2024
61d6a0f
Merge branch 'main' into releases/2.3.0
stanleyyconsensys Jun 12, 2024
2fedd78
chore: lint style
stanleyyconsensys Jun 12, 2024
b5cd8c6
fix: lint issue
stanleyyconsensys Jun 12, 2024
17f5975
fix: yarn lock
stanleyyconsensys Jun 12, 2024
fe5631d
Merge branch 'main' into releases/2.3.0
stanleyyconsensys Jun 12, 2024
3209fe3
chore: add update text
stanleyyconsensys Jun 13, 2024
d695ead
chore: update snap file
stanleyyconsensys Jun 13, 2024
47ffbb5
chore: update yarn.lock
stanleyyconsensys Jun 13, 2024
450376c
Merge branch 'releases/2.3.0' into feat/sf-618
khanti42 Jun 17, 2024
cbd9ead
style: prettier
khanti42 Jun 17, 2024
81f5dfa
fix: await missing in some upgradeRequired check
khanti42 Jun 17, 2024
1f602a7
Merge branch 'main' into feat/sf-618
khanti42 Jun 17, 2024
cfbbed1
test: updated unit testing associated to get-starknet
khanti42 Jun 17, 2024
f783bf5
fix: adapted text of the upgradeRequestModal
khanti42 Jun 17, 2024
a0a03fa
style: lint
khanti42 Jun 17, 2024
0af0afb
chore: update snap sdk
stanleyyconsensys Jun 18, 2024
20f4fac
chore: update snap sdk
stanleyyconsensys Jun 18, 2024
3718151
Merge branch 'releases/2.3.0' into feat/sf-618
khanti42 Jun 18, 2024
076cf4a
fix: manifest
khanti42 Jun 18, 2024
4de9b46
test: fix on executTxn.test.ts
khanti42 Jun 18, 2024
d3e17ff
Merge branch 'main' into feat/sf-618
khanti42 Jun 20, 2024
4ee1864
Merge branch 'main' into feat/sf-618
khanti42 Jun 20, 2024
1605a16
fix: executeTxn with deployed cairov2 should not trigger deployment
khanti42 Jun 20, 2024
ac2f797
fix: resolve local build get-starknet config issue
stanleyyconsensys Jun 21, 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
Merge branch 'main' into feat/sf-614-rebase
  • Loading branch information
stanleyyconsensys committed Jun 3, 2024
commit a776b049d40ffc110f13df63e42d5b49d26435f1
2 changes: 1 addition & 1 deletion packages/starknet-snap/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/ConsenSys/starknet-snap.git"
},
"source": {
"shasum": "l+wa5VCGkesCafIYs/fVnQHsiooEg/z+IcCcXNiP0vo=",
"shasum": "trDDU4ANftSs6SE0RJK3uXaxRnCBq7fvgptzA280SPA=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
51 changes: 38 additions & 13 deletions packages/starknet-snap/src/utils/starknetUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ import {
DeclareSignerDetails,
DeployAccountSignerDetails,
CairoVersion,
InvocationsSignerDetails,
ProviderInterface,
} from 'starknet';
import { Network, SnapState, Transaction, TransactionType } from '../types/snapState';
import {
Expand Down Expand Up @@ -103,12 +105,11 @@ export const declareContract = async (
senderAddress: string,
privateKey: string | Uint8Array,
contractPayload: DeclareContractPayload,
transactionsDetail?: InvocationsDetails,
invocationsDetails?: UniversalDetails,
cairoVersion?: CairoVersion,
): Promise<DeclareContractResponse> => {
return getAccountInstance(network, senderAddress, privateKey, cairoVersion).declare(
contractPayload,
transactionsDetail,
contractPayload, { ...invocationsDetails, skipValidate: false, blockIdentifier: 'latest' }
);
};

Expand All @@ -118,8 +119,11 @@ export const estimateFee = async (
privateKey: string | Uint8Array,
txnInvocation: Call | Call[],
cairoVersion?: CairoVersion,
invocationsDetails?: UniversalDetails,
): Promise<EstimateFee> => {
return getAccountInstance(network, senderAddress, privateKey, cairoVersion).estimateInvokeFee(txnInvocation, {
...invocationsDetails,
skipValidate: false,
blockIdentifier: 'latest',
});
};
Expand All @@ -129,12 +133,16 @@ export const estimateFeeBulk = async (
senderAddress: string,
privateKey: string | Uint8Array,
txnInvocation: Invocations,
invocationsDetails: EstimateFeeDetails = { blockIdentifier: 'latest' },
invocationsDetails: UniversalDetails,
cairoVersion?: CairoVersion,
): Promise<EstimateFee[]> => {
return getAccountInstance(network, senderAddress, privateKey, cairoVersion).estimateFeeBulk(
txnInvocation,
invocationsDetails,
{
...invocationsDetails,
skipValidate: false,
blockIdentifier: 'latest',
},
);
};

Expand All @@ -144,13 +152,17 @@ export const executeTxn = async (
privateKey: string | Uint8Array,
txnInvocation: Call | Call[],
abis?: Abi[],
invocationsDetails?: InvocationsDetails,
invocationsDetails?: UniversalDetails,
cairoVersion?: CairoVersion,
): Promise<InvokeFunctionResponse> => {
return getAccountInstance(network, senderAddress, privateKey, cairoVersion).execute(
txnInvocation,
abis,
invocationsDetails,
{
...invocationsDetails,
skipValidate: false,
blockIdentifier: 'latest',
},
);
};

Expand All @@ -162,6 +174,7 @@ export const deployAccount = async (
privateKey: string | Uint8Array,
maxFee: num.BigNumberish,
cairoVersion?: CairoVersion,
invocationsDetails?: UniversalDetails,
): Promise<DeployContractResponse> => {
const deployAccountPayload = {
classHash: ACCOUNT_CLASS_HASH,
Expand All @@ -170,6 +183,9 @@ export const deployAccount = async (
addressSalt,
};
return getAccountInstance(network, contractAddress, privateKey, cairoVersion).deployAccount(deployAccountPayload, {
...invocationsDetails,
skipValidate: false,
blockIdentifier: 'latest',
maxFee,
});
};
Expand All @@ -181,6 +197,7 @@ export const estimateAccountDeployFee = async (
addressSalt: num.BigNumberish,
privateKey: string | Uint8Array,
cairoVersion?: CairoVersion,
invocationsDetails?: UniversalDetails,
): Promise<EstimateFee> => {
const deployAccountPayload = {
classHash: ACCOUNT_CLASS_HASH,
Expand All @@ -190,6 +207,11 @@ export const estimateAccountDeployFee = async (
};
return getAccountInstance(network, contractAddress, privateKey, cairoVersion).estimateAccountDeployFee(
deployAccountPayload,
{
...invocationsDetails,
skipValidate: false,
blockIdentifier: 'latest',
}
);
};

Expand All @@ -200,12 +222,12 @@ export const getSigner = async (userAccAddress: string, network: Network): Promi

export const getVersion = async (userAccAddress: string, network: Network): Promise<string> => {
const resp = await callContract(network, userAccAddress, 'getVersion');
return resp.result[0];
return resp[0];
};

export const getOwner = async (userAccAddress: string, network: Network): Promise<string> => {
const resp = await callContract(network, userAccAddress, 'get_owner');
return resp.result[0];
return resp[0];
};

export const getContractOwner = async (
Expand All @@ -218,7 +240,7 @@ export const getContractOwner = async (

export const getBalance = async (address: string, tokenAddress: string, network: Network) => {
const resp = await callContract(network, tokenAddress, 'balanceOf', [num.toBigInt(address).toString(10)]);
return resp.result[0];
return resp[0];
};

export const getTransactionStatus = async (transactionHash: num.BigNumberish, network: Network) => {
Expand Down Expand Up @@ -360,9 +382,12 @@ export const getMassagedTransactions = async (
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
contractAddress: txnResp.calldata?.[1] || txnResp.contract_address || txn.contract_address || '',
contractFuncName:
num.toBigInt(txnResp.calldata?.[2] || '') === bigIntTransferSelectorHex ? 'transfer' : txn.operations ?? '',
contractCallData: txnResp.calldata || [],
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
contractFuncName: num.toBigInt(txnResp.calldata?.[2] || '') === bigIntTransferSelectorHex ? 'transfer' : txn.operations ?? '',
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
contractCallData: txnResp.calldata?.slice(6, txnResp.calldata?.length - 1) || [],
timestamp: txn.timestamp,
status: '', //DEPRECATION
finalityStatus: statusResp.finalityStatus || '',
Expand Down
2 changes: 1 addition & 1 deletion packages/starknet-snap/test/constants.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { JsonBIP44CoinTypeNode } from '@metamask/key-tree';
import { num, constants } from 'starknet';
import { EstimateFee, GetTransactionResponse, constants } from 'starknet';
import {
AccContract,
Erc20Token,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,7 @@ describe('Test function: signDeclareTransaction', function () {
const requestObject: SignDeclareTransactionRequestParams = {
chainId: STARKNET_SEPOLIA_TESTNET_NETWORK.chainId,
signerAddress: account1.address,
transaction: {
classHash: '0x025ec026985a3bf9d0cc1fe17326b245dfdc3ff89b8fde106542a3ea56c5a918',
senderAddress: account1.address,
chainId: constants.StarknetChainId.SN_GOERLI,
nonce: '0x1',
version: '0x0',
maxFee: 100,
},
transaction: declarePayload,
enableAuthorize: true,
};

Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3245,8 +3245,8 @@ __metadata:
linkType: soft

"@consensys/starknet-snap@file:../starknet-snap::locator=wallet-ui%40workspace%3Apackages%2Fwallet-ui":
version: 2.6.1
resolution: "@consensys/starknet-snap@file:../starknet-snap#../starknet-snap::hash=b7e81c&locator=wallet-ui%40workspace%3Apackages%2Fwallet-ui"
version: 2.7.0
resolution: "@consensys/starknet-snap@file:../starknet-snap#../starknet-snap::hash=660e3f&locator=wallet-ui%40workspace%3Apackages%2Fwallet-ui"
dependencies:
"@metamask/snaps-sdk": 3.0.1
async-mutex: ^0.3.2
Expand All @@ -3255,7 +3255,7 @@ __metadata:
ethers: ^5.5.1
starknet: 6.7.0
starknet_v4.22.0: "npm:starknet@4.22.0"
checksum: cb88578a94965f39209e923ac4d0d68e55d3a715fc2a8066afd062f2d27af994c2b56b63ff4176f21003a5e0164a465848a51d575f48c6d36fb318be4d4374de
checksum: 983f842b9dba2bec7cfcd8907f9dd8d420befc61e045b7138f1786f1662ff6c4f3279b8db49193cf2ae39dff0b9173a5475d1b072f918fda72d54d9d05d4bfd5
languageName: node
linkType: hard

Expand Down
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.