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: upgrade to sarknet.js v6.11.0 #296

Merged
merged 21 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
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
2 changes: 1 addition & 1 deletion packages/get-starknet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@
"registry": "https://registry.npmjs.org/"
},
"dependencies": {
"starknet": "^5.14.0"
"starknet": "6.11.0"
}
}
7 changes: 5 additions & 2 deletions packages/get-starknet/src/accounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,13 @@ export class MetaMaskAccount extends Account {

async execute(
calls: AllowArray<Call>,
abis?: Abi[] | undefined,
abisOrTransactionsDetail?: Abi[] | InvocationsDetails,
transactionsDetail?: InvocationsDetails,
): Promise<InvokeFunctionResponse> {
return this.#snap.execute(this.#address, calls, abis, transactionsDetail);
if (!transactionsDetail) {
return this.#snap.execute(this.#address, calls, undefined, abisOrTransactionsDetail as InvocationsDetails);
}
return this.#snap.execute(this.#address, calls, abisOrTransactionsDetail as Abi[], transactionsDetail);
}

async signMessage(typedData: TypedData): Promise<Signature> {
Expand Down
4 changes: 1 addition & 3 deletions packages/get-starknet/src/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,7 @@ export class MetaMaskSnapWallet implements IStarknetWindowObject {

async #getRPCProvider(network: { chainId: string; nodeUrl: string }) {
return new Provider({
rpc: {
nodeUrl: network.nodeUrl,
},
nodeUrl: network.nodeUrl,
});
}

Expand Down
2 changes: 1 addition & 1 deletion packages/starknet-snap/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"async-mutex": "^0.3.2",
"ethereum-unit-converter": "^0.0.17",
"ethers": "^5.5.1",
"starknet": "6.7.0",
"starknet": "6.11.0",
"starknet_v4.22.0": "npm:[email protected]"
},
"devDependencies": {
Expand Down
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": "QTghmF19ZVAMHyKpyNlzjdwLvzrP6RHVWLfZzZHjynU=",
"shasum": "uG3NeaD7Ky06SZo9Hnx1KWn5EjavmUJC5VBSY/sqctM=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
19 changes: 6 additions & 13 deletions packages/starknet-snap/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ import {
ETHER_MAINNET,
ETHER_SEPOLIA_TESTNET,
PRELOADED_TOKENS,
STARKNET_INTEGRATION_NETWORK,
STARKNET_MAINNET_NETWORK,
STARKNET_SEPOLIA_TESTNET_NETWORK,
STARKNET_TESTNET_NETWORK,
Expand Down Expand Up @@ -89,8 +88,6 @@ export const onRpcRequest: OnRpcRequestHandler = async ({ request }) => {
logger.log(`${request.method}:\nrequestParams: ${toJson(requestParams)}`);

try {
const isDev = Boolean(requestParams?.isDev);

if (request.method === 'ping') {
logger.log('pong');
return 'pong';
Expand Down Expand Up @@ -120,16 +117,12 @@ export const onRpcRequest: OnRpcRequestHandler = async ({ request }) => {
}
// pre-inserted the default networks and tokens
await upsertNetwork(STARKNET_MAINNET_NETWORK, snap, saveMutex, state);
if (isDev) {
await upsertNetwork(STARKNET_INTEGRATION_NETWORK, snap, saveMutex, state);
} else {
await upsertNetwork(
STARKNET_SEPOLIA_TESTNET_NETWORK,
snap,
saveMutex,
state,
);
}
await upsertNetwork(
STARKNET_SEPOLIA_TESTNET_NETWORK,
snap,
saveMutex,
state,
);

// remove the testnet network (migration)
await removeNetwork(STARKNET_TESTNET_NETWORK, snap, saveMutex, state);
Expand Down
1 change: 0 additions & 1 deletion packages/starknet-snap/src/types/snapApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ export type ApiRequestParams =

export type BaseRequestParams = {
chainId?: string;
isDev?: boolean;
debugLevel?: string;
};

Expand Down
10 changes: 0 additions & 10 deletions packages/starknet-snap/src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,6 @@ export const STARKNET_SEPOLIA_TESTNET_NETWORK: Network = {
accountClassHash: '', // from argent-x repo
};

export const STARKNET_INTEGRATION_NETWORK: Network = {
name: 'Goerli Integration',
chainId: constants.StarknetChainId.SN_GOERLI,
baseUrl: 'https://external.integration.starknet.io',
nodeUrl: '',
voyagerUrl: '',
accountClassHash: '',
};

export const ETHER_MAINNET: Erc20Token = {
address: '0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7',
name: 'Ether',
Expand Down Expand Up @@ -182,7 +173,6 @@ export const PRELOADED_TOKENS = [
export const PRELOADED_NETWORKS = [
STARKNET_MAINNET_NETWORK,
STARKNET_SEPOLIA_TESTNET_NETWORK,
STARKNET_INTEGRATION_NETWORK,
];

export const PROXY_CONTRACT_HASH =
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
Expand Up @@ -83,7 +83,7 @@ export const Cairo1Account1: AccContract = {
'0x5bc00132b8f2fc0f673dc232594b26727e712b204a2716f9dc28a8c5f607b5e',
publicKey:
'0x019e59f349e1aa813ab4556c5836d0472e5e1ae82d1e5c3b3e8aabfeb290befd',
chainId: constants.StarknetChainId.SN_GOERLI,
chainId: constants.StarknetChainId.SN_SEPOLIA,
};

export const token0: Erc20Token = {
Expand Down
2 changes: 1 addition & 1 deletion packages/wallet-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"react-redux": "^8.0.1",
"redux-persist": "^6.0.0",
"semver": "^7.5.2",
"starknet": "^4.22.0",
"starknet": "6.11.0",
"styled-components": "^5.3.5",
"toastr2": "^3.0.0-alpha.18",
"web-vitals": "^2.1.4"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default {
const asset = {
address: '0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7',
amount: BigNumber.from('1000000000000000000'),
chainId: constants.StarknetChainId.TESTNET,
chainId: constants.StarknetChainId.SN_SEPOLIA,
decimals: 18,
name: 'Ether',
symbol: 'ETH',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default {
const asset: Erc20TokenBalance = {
address: '0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7',
amount: BigNumber.from('1000000000000000000'),
chainId: constants.StarknetChainId.TESTNET,
chainId: constants.StarknetChainId.SN_SEPOLIA,
decimals: 18,
name: 'Ether',
symbol: 'ETH',
Expand Down
2 changes: 1 addition & 1 deletion packages/wallet-ui/src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { constants } from 'starknet';
export const SEPOLIA_CHAINID = '0x534e5f5345504f4c4941';

export const TOKENS: any = {
[constants.StarknetChainId.MAINNET]: {
[constants.StarknetChainId.SN_MAIN]: {
'0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7': {
coingeckoId: 'ethereum',
},
Expand Down
2 changes: 1 addition & 1 deletion packages/wallet-ui/src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const openExplorerTab = (
) => {
let explorerUrl = STARKNET_SEPOLIA_TESTNET_EXPLORER;
switch (chainId) {
case constants.StarknetChainId.MAINNET:
case constants.StarknetChainId.SN_MAIN:
explorerUrl = STARKNET_MAINNET_EXPLORER;
break;
case SEPOLIA_CHAINID:
Expand Down
Loading
Loading