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: dep starknet-types #1053

Merged
merged 4 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@
"@scure/starknet": "~1.0.0",
"abi-wan-kanabi": "^2.2.2",
"fetch-cookie": "^3.0.0",
"get-starknet-core": "^4.0.0-next.3",
"isomorphic-fetch": "^3.0.0",
"lossless-json": "^4.0.1",
"pako": "^2.0.4",
"starknet-types": "^0.0.4",
"ts-mixer": "^6.0.3",
"url-join": "^4.0.1"
},
Expand Down
59 changes: 9 additions & 50 deletions src/types/typedData.ts
Original file line number Diff line number Diff line change
@@ -1,50 +1,9 @@
export enum TypedDataRevision {
Active = '1',
Legacy = '0',
}

export type StarknetEnumType = {
name: string;
type: 'enum';
contains: string;
};

export type StarknetMerkleType = {
name: string;
type: 'merkletree';
contains: string;
};

/**
* A single type, as part of a struct. The `type` field can be any of the EIP-712 supported types.
*
* Note that the `uint` and `int` aliases like in Solidity, and fixed point numbers are not supported by the EIP-712
* standard.
*/
export type StarknetType =
| {
name: string;
type: string;
}
| StarknetEnumType
| StarknetMerkleType;

/**
* The EIP712 domain struct. Any of these fields are optional, but it must contain at least one field.
*/
export interface StarknetDomain extends Record<string, unknown> {
name?: string;
version?: string;
chainId?: string | number;
revision?: string;
}

/**
* The complete typed data, with all the structs, domain data, primary type of the message, and the message itself.
*/
export interface TypedData {
types: Record<string, StarknetType[]>;
primaryType: string;
domain: StarknetDomain;
message: Record<string, unknown>;
}
// Reexport types from package
export {
TypedDataRevision,
type StarknetEnumType,
type StarknetMerkleType,
type StarknetType,
type StarknetDomain,
type TypedData,
} from 'starknet-types';
5 changes: 3 additions & 2 deletions src/wallet/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import {
type AddStarknetChainParameters,
type NetworkChangeEventHandler,
type WatchAssetParameters,
} from 'get-starknet-core';
} from 'starknet-types';

import { Account, AccountInterface } from '../account';
import { StarknetChainId } from '../constants';
import { ProviderInterface } from '../provider';
import {
AllowArray,
Expand Down Expand Up @@ -37,6 +37,7 @@ import {
watchAsset,
} from './connect';
import { StarknetWalletProvider } from './types';
import { StarknetChainId } from '../constants';

// Represent 'Selected Active' Account inside Connected Wallet
export class WalletAccount extends Account implements AccountInterface {
Expand Down
2 changes: 1 addition & 1 deletion src/wallet/connect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
type StarknetChainId,
type StarknetWindowObject,
type TypedData,
} from 'get-starknet-core';
} from 'starknet-types';

/**
* Request Permission for wallet account, return addresses that are allowed by user
Expand Down
2 changes: 1 addition & 1 deletion src/wallet/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type RpcMessage, type StarknetWindowObject } from 'get-starknet-core';
import { type RpcMessage, type StarknetWindowObject } from 'starknet-types';

// ---- TT Request Handler
export type RpcCall = Omit<RpcMessage, 'result'>;
Expand Down