@imtbl/passport 2.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +176 -0
- package/README.md +60 -0
- package/dist/browser/index.js +332 -0
- package/dist/node/index.cjs +332 -0
- package/dist/node/index.js +332 -0
- package/dist/types/Passport.d.ts +84 -0
- package/dist/types/Passport.int.test.d.ts +1 -0
- package/dist/types/Passport.test.d.ts +1 -0
- package/dist/types/authManager.d.ts +59 -0
- package/dist/types/authManager.test.d.ts +1 -0
- package/dist/types/config/config.d.ts +20 -0
- package/dist/types/config/config.test.d.ts +1 -0
- package/dist/types/config/index.d.ts +1 -0
- package/dist/types/confirmation/confirmation.d.ts +28 -0
- package/dist/types/confirmation/confirmation.test.d.ts +1 -0
- package/dist/types/confirmation/index.d.ts +2 -0
- package/dist/types/confirmation/popup.d.ts +8 -0
- package/dist/types/confirmation/popup.test.d.ts +1 -0
- package/dist/types/confirmation/types.d.ts +16 -0
- package/dist/types/errors/passportError.d.ts +30 -0
- package/dist/types/errors/passportError.test.d.ts +1 -0
- package/dist/types/guardian/index.d.ts +57 -0
- package/dist/types/guardian/index.test.d.ts +1 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/magicAdapter.d.ts +10 -0
- package/dist/types/magicAdapter.test.d.ts +1 -0
- package/dist/types/mocks/zkEvm/msw.d.ts +29 -0
- package/dist/types/network/chains.d.ts +32 -0
- package/dist/types/network/constants.d.ts +3 -0
- package/dist/types/network/retry.d.ts +8 -0
- package/dist/types/network/retry.test.d.ts +1 -0
- package/dist/types/overlay/constants.d.ts +6 -0
- package/dist/types/overlay/elements.d.ts +10 -0
- package/dist/types/overlay/index.d.ts +17 -0
- package/dist/types/overlay/overlay.test.d.ts +1 -0
- package/dist/types/starkEx/getStarkSigner.d.ts +3 -0
- package/dist/types/starkEx/getStarkSigner.test.d.ts +1 -0
- package/dist/types/starkEx/index.d.ts +4 -0
- package/dist/types/starkEx/passportImxProvider.d.ts +48 -0
- package/dist/types/starkEx/passportImxProvider.test.d.ts +1 -0
- package/dist/types/starkEx/passportImxProviderFactory.d.ts +28 -0
- package/dist/types/starkEx/passportImxProviderFactory.test.d.ts +1 -0
- package/dist/types/starkEx/workflows/exchange.d.ts +11 -0
- package/dist/types/starkEx/workflows/exchange.test.d.ts +1 -0
- package/dist/types/starkEx/workflows/index.d.ts +5 -0
- package/dist/types/starkEx/workflows/order.d.ts +21 -0
- package/dist/types/starkEx/workflows/order.test.d.ts +1 -0
- package/dist/types/starkEx/workflows/registerOffchain.d.ts +5 -0
- package/dist/types/starkEx/workflows/registerOffchain.test.d.ts +1 -0
- package/dist/types/starkEx/workflows/registration.d.ts +6 -0
- package/dist/types/starkEx/workflows/registration.test.d.ts +1 -0
- package/dist/types/starkEx/workflows/trades.d.ts +13 -0
- package/dist/types/starkEx/workflows/trades.test.d.ts +1 -0
- package/dist/types/starkEx/workflows/transfer.d.ts +21 -0
- package/dist/types/starkEx/workflows/transfer.test.d.ts +1 -0
- package/dist/types/storage/LocalForageAsyncStorage.d.ts +11 -0
- package/dist/types/storage/device_credentials_manager.d.ts +7 -0
- package/dist/types/test/mocks.d.ts +56 -0
- package/dist/types/types.d.ts +166 -0
- package/dist/types/utils/lazyLoad.d.ts +2 -0
- package/dist/types/utils/lazyLoad.test.d.ts +1 -0
- package/dist/types/utils/logger.d.ts +4 -0
- package/dist/types/utils/metrics.d.ts +3 -0
- package/dist/types/utils/metrics.test.d.ts +1 -0
- package/dist/types/utils/string.d.ts +1 -0
- package/dist/types/utils/string.test.d.ts +1 -0
- package/dist/types/utils/token.d.ts +3 -0
- package/dist/types/utils/token.test.d.ts +1 -0
- package/dist/types/utils/typedEventEmitter.d.ts +6 -0
- package/dist/types/utils/typedEventEmitter.test.d.ts +1 -0
- package/dist/types/zkEvm/JsonRpcError.d.ts +25 -0
- package/dist/types/zkEvm/index.d.ts +2 -0
- package/dist/types/zkEvm/personalSign.d.ts +15 -0
- package/dist/types/zkEvm/personalSign.test.d.ts +1 -0
- package/dist/types/zkEvm/provider/eip6963.d.ts +3 -0
- package/dist/types/zkEvm/relayerClient.d.ts +59 -0
- package/dist/types/zkEvm/relayerClient.test.d.ts +1 -0
- package/dist/types/zkEvm/sendDeployTransactionAndPersonalSign.d.ts +6 -0
- package/dist/types/zkEvm/sendDeployTransactionAndPersonalSign.test.d.ts +1 -0
- package/dist/types/zkEvm/sendTransaction.d.ts +6 -0
- package/dist/types/zkEvm/sendTransaction.test.d.ts +1 -0
- package/dist/types/zkEvm/sessionActivity/errorBoundary.d.ts +1 -0
- package/dist/types/zkEvm/sessionActivity/request.d.ts +15 -0
- package/dist/types/zkEvm/sessionActivity/sessionActivity.d.ts +2 -0
- package/dist/types/zkEvm/signEjectionTransaction.d.ts +6 -0
- package/dist/types/zkEvm/signEjectionTransaction.test.d.ts +1 -0
- package/dist/types/zkEvm/signTypedDataV4.d.ts +14 -0
- package/dist/types/zkEvm/signTypedDataV4.test.d.ts +1 -0
- package/dist/types/zkEvm/transactionHelpers.d.ts +29 -0
- package/dist/types/zkEvm/transactionHelpers.test.d.ts +1 -0
- package/dist/types/zkEvm/types.d.ts +114 -0
- package/dist/types/zkEvm/user/index.d.ts +1 -0
- package/dist/types/zkEvm/user/registerZkEvmUser.d.ts +13 -0
- package/dist/types/zkEvm/user/registerZkEvmUser.test.d.ts +1 -0
- package/dist/types/zkEvm/walletHelpers.d.ts +12 -0
- package/dist/types/zkEvm/walletHelpers.test.d.ts +1 -0
- package/dist/types/zkEvm/zkEvmProvider.d.ts +24 -0
- package/dist/types/zkEvm/zkEvmProvider.test.d.ts +1 -0
- package/package.json +90 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { imx } from '@imtbl/generated-clients';
|
|
2
|
+
import { StarkSigner, NftTransferDetails, UnsignedTransferRequest } from '@imtbl/x-client';
|
|
3
|
+
import { UserImx } from '../../types';
|
|
4
|
+
import GuardianClient from '../../guardian';
|
|
5
|
+
type TransferRequest = {
|
|
6
|
+
request: UnsignedTransferRequest;
|
|
7
|
+
user: UserImx;
|
|
8
|
+
starkSigner: StarkSigner;
|
|
9
|
+
transfersApi: imx.TransfersApi;
|
|
10
|
+
guardianClient: GuardianClient;
|
|
11
|
+
};
|
|
12
|
+
type BatchTransfersParams = {
|
|
13
|
+
request: Array<NftTransferDetails>;
|
|
14
|
+
user: UserImx;
|
|
15
|
+
starkSigner: StarkSigner;
|
|
16
|
+
transfersApi: imx.TransfersApi;
|
|
17
|
+
guardianClient: GuardianClient;
|
|
18
|
+
};
|
|
19
|
+
export declare function transfer({ request, transfersApi, starkSigner, user, guardianClient, }: TransferRequest): Promise<imx.CreateTransferResponseV1>;
|
|
20
|
+
export declare function batchNftTransfer({ user, starkSigner, request, transfersApi, guardianClient, }: BatchTransfersParams): Promise<imx.CreateTransferResponse>;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AsyncStorage } from 'oidc-client-ts';
|
|
2
|
+
export declare class LocalForageAsyncStorage implements AsyncStorage {
|
|
3
|
+
private storage;
|
|
4
|
+
constructor(name: string, driver: string | string[]);
|
|
5
|
+
get length(): Promise<number>;
|
|
6
|
+
clear(): Promise<void>;
|
|
7
|
+
getItem(key: string): Promise<string | null>;
|
|
8
|
+
key(index: number): Promise<string | null>;
|
|
9
|
+
removeItem(key: string): Promise<void>;
|
|
10
|
+
setItem(key: string, value: string): Promise<void>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { User, UserImx, UserZkEvm } from '../types';
|
|
2
|
+
import { PassportConfiguration } from '../config';
|
|
3
|
+
import { ChainId } from '../network/chains';
|
|
4
|
+
export declare const mockErrorMessage = "Server is down";
|
|
5
|
+
export declare const mockStarkSignature = "starkSignature";
|
|
6
|
+
export declare const chainId = ChainId.IMTBL_ZKEVM_TESTNET;
|
|
7
|
+
export declare const chainIdHex = "0x34a1";
|
|
8
|
+
export declare const chainIdEip155 = "eip155:13473";
|
|
9
|
+
export declare const testConfig: PassportConfiguration;
|
|
10
|
+
export declare const mockUser: User;
|
|
11
|
+
export declare const mockUserImx: UserImx;
|
|
12
|
+
export declare const mockUserZkEvm: UserZkEvm;
|
|
13
|
+
export declare const mockLinkedAddresses: {
|
|
14
|
+
data: {
|
|
15
|
+
sub: string;
|
|
16
|
+
linked_addresses: string[];
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
export declare const mockListChains: {
|
|
20
|
+
data: {
|
|
21
|
+
result: {
|
|
22
|
+
id: string;
|
|
23
|
+
name: string;
|
|
24
|
+
rpc_url: string;
|
|
25
|
+
}[];
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
export declare const mockLinkedWallet: {
|
|
29
|
+
data: {
|
|
30
|
+
address: string;
|
|
31
|
+
type: string;
|
|
32
|
+
created_at: string;
|
|
33
|
+
updated_at: string;
|
|
34
|
+
name: string;
|
|
35
|
+
clientName: string;
|
|
36
|
+
};
|
|
37
|
+
status: number;
|
|
38
|
+
};
|
|
39
|
+
export declare const mockApiError: {
|
|
40
|
+
response: {
|
|
41
|
+
data: {
|
|
42
|
+
code: string;
|
|
43
|
+
message: string;
|
|
44
|
+
};
|
|
45
|
+
status: number;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
export declare const mockPassportBadRequest: {
|
|
49
|
+
response: {
|
|
50
|
+
data: {
|
|
51
|
+
code: string;
|
|
52
|
+
message: string;
|
|
53
|
+
};
|
|
54
|
+
status: number;
|
|
55
|
+
};
|
|
56
|
+
};
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { Environment, ModuleConfiguration } from '@imtbl/config';
|
|
2
|
+
import { EthSigner, IMXClient, StarkSigner } from '@imtbl/x-client';
|
|
3
|
+
import { ImxApiClients } from '@imtbl/generated-clients';
|
|
4
|
+
import { Flow } from '@imtbl/metrics';
|
|
5
|
+
export declare enum PassportEvents {
|
|
6
|
+
LOGGED_OUT = "loggedOut",
|
|
7
|
+
LOGGED_IN = "loggedIn",
|
|
8
|
+
ACCOUNTS_REQUESTED = "accountsRequested"
|
|
9
|
+
}
|
|
10
|
+
export type AccountsRequestedEvent = {
|
|
11
|
+
environment: Environment;
|
|
12
|
+
sendTransaction: (params: Array<any>, flow: Flow) => Promise<string>;
|
|
13
|
+
walletAddress: string;
|
|
14
|
+
passportClient: string;
|
|
15
|
+
flow?: Flow;
|
|
16
|
+
};
|
|
17
|
+
export interface PassportEventMap extends Record<string, any> {
|
|
18
|
+
[PassportEvents.LOGGED_OUT]: [];
|
|
19
|
+
[PassportEvents.LOGGED_IN]: [User];
|
|
20
|
+
[PassportEvents.ACCOUNTS_REQUESTED]: [AccountsRequestedEvent];
|
|
21
|
+
}
|
|
22
|
+
export type UserProfile = {
|
|
23
|
+
email?: string;
|
|
24
|
+
nickname?: string;
|
|
25
|
+
sub: string;
|
|
26
|
+
};
|
|
27
|
+
export type User = {
|
|
28
|
+
idToken?: string;
|
|
29
|
+
accessToken: string;
|
|
30
|
+
refreshToken?: string;
|
|
31
|
+
profile: UserProfile;
|
|
32
|
+
expired?: boolean;
|
|
33
|
+
imx?: {
|
|
34
|
+
ethAddress: string;
|
|
35
|
+
starkAddress: string;
|
|
36
|
+
userAdminAddress: string;
|
|
37
|
+
};
|
|
38
|
+
zkEvm?: {
|
|
39
|
+
ethAddress: string;
|
|
40
|
+
userAdminAddress: string;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
export type PassportMetadata = {
|
|
44
|
+
imx_eth_address: string;
|
|
45
|
+
imx_stark_address: string;
|
|
46
|
+
imx_user_admin_address: string;
|
|
47
|
+
zkevm_eth_address: string;
|
|
48
|
+
zkevm_user_admin_address: string;
|
|
49
|
+
};
|
|
50
|
+
export interface OidcConfiguration {
|
|
51
|
+
clientId: string;
|
|
52
|
+
logoutRedirectUri?: string;
|
|
53
|
+
logoutMode?: 'redirect' | 'silent';
|
|
54
|
+
redirectUri: string;
|
|
55
|
+
scope?: string;
|
|
56
|
+
audience?: string;
|
|
57
|
+
}
|
|
58
|
+
export interface PassportOverrides {
|
|
59
|
+
authenticationDomain: string;
|
|
60
|
+
magicPublishableApiKey: string;
|
|
61
|
+
magicProviderId: string;
|
|
62
|
+
passportDomain: string;
|
|
63
|
+
imxPublicApiDomain: string;
|
|
64
|
+
immutableXClient: IMXClient;
|
|
65
|
+
zkEvmRpcUrl: string;
|
|
66
|
+
relayerUrl: string;
|
|
67
|
+
indexerMrBasePath: string;
|
|
68
|
+
orderBookMrBasePath: string;
|
|
69
|
+
passportMrBasePath: string;
|
|
70
|
+
imxApiClients?: ImxApiClients;
|
|
71
|
+
}
|
|
72
|
+
export interface PopupOverlayOptions {
|
|
73
|
+
disableGenericPopupOverlay?: boolean;
|
|
74
|
+
disableBlockedPopupOverlay?: boolean;
|
|
75
|
+
}
|
|
76
|
+
export interface PassportModuleConfiguration extends ModuleConfiguration<PassportOverrides>, OidcConfiguration {
|
|
77
|
+
/**
|
|
78
|
+
* This flag indicates that Passport is being used in a cross-sdk bridge scenario
|
|
79
|
+
* and not directly on the web.
|
|
80
|
+
*/
|
|
81
|
+
crossSdkBridgeEnabled?: boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Optional referrer URL to be sent with JSON-RPC requests.
|
|
84
|
+
* If specified, this value will be passed as the referrer in fetch options.
|
|
85
|
+
*/
|
|
86
|
+
jsonRpcReferrer?: string;
|
|
87
|
+
/**
|
|
88
|
+
* Options for disabling the Passport popup overlays.
|
|
89
|
+
*/
|
|
90
|
+
popupOverlayOptions?: PopupOverlayOptions;
|
|
91
|
+
/**
|
|
92
|
+
* This flag controls whether a deploy transaction is sent before signing an ERC191 message.
|
|
93
|
+
*
|
|
94
|
+
* @default false - By default, this behavior is disabled and the user will not be asked
|
|
95
|
+
* to approve a deploy transaction before signing.
|
|
96
|
+
*/
|
|
97
|
+
forceScwDeployBeforeMessageSignature?: boolean;
|
|
98
|
+
}
|
|
99
|
+
type WithRequired<T, K extends keyof T> = T & {
|
|
100
|
+
[P in K]-?: T[P];
|
|
101
|
+
};
|
|
102
|
+
export type UserImx = WithRequired<User, 'imx'>;
|
|
103
|
+
export type UserZkEvm = WithRequired<User, 'zkEvm'>;
|
|
104
|
+
export declare const isUserZkEvm: (user: User) => user is UserZkEvm;
|
|
105
|
+
export declare const isUserImx: (user: User) => user is UserImx;
|
|
106
|
+
export type DeviceConnectResponse = {
|
|
107
|
+
code: string;
|
|
108
|
+
deviceCode: string;
|
|
109
|
+
url: string;
|
|
110
|
+
interval: number;
|
|
111
|
+
};
|
|
112
|
+
export type DeviceCodeResponse = {
|
|
113
|
+
device_code: string;
|
|
114
|
+
user_code: string;
|
|
115
|
+
verification_uri: string;
|
|
116
|
+
expires_in: number;
|
|
117
|
+
interval: number;
|
|
118
|
+
verification_uri_complete: string;
|
|
119
|
+
};
|
|
120
|
+
export type DeviceTokenResponse = {
|
|
121
|
+
access_token: string;
|
|
122
|
+
refresh_token?: string;
|
|
123
|
+
id_token: string;
|
|
124
|
+
token_type: string;
|
|
125
|
+
expires_in: number;
|
|
126
|
+
};
|
|
127
|
+
export type TokenPayload = {
|
|
128
|
+
exp?: number;
|
|
129
|
+
};
|
|
130
|
+
export type IdTokenPayload = {
|
|
131
|
+
passport?: PassportMetadata;
|
|
132
|
+
email: string;
|
|
133
|
+
nickname: string;
|
|
134
|
+
aud: string;
|
|
135
|
+
sub: string;
|
|
136
|
+
exp: number;
|
|
137
|
+
iss: string;
|
|
138
|
+
iat: number;
|
|
139
|
+
};
|
|
140
|
+
export type DeviceErrorResponse = {
|
|
141
|
+
error: string;
|
|
142
|
+
error_description: string;
|
|
143
|
+
};
|
|
144
|
+
export type PKCEData = {
|
|
145
|
+
state: string;
|
|
146
|
+
verifier: string;
|
|
147
|
+
};
|
|
148
|
+
export type IMXSigners = {
|
|
149
|
+
starkSigner: StarkSigner;
|
|
150
|
+
ethSigner: EthSigner;
|
|
151
|
+
};
|
|
152
|
+
export type LinkWalletParams = {
|
|
153
|
+
type: string;
|
|
154
|
+
walletAddress: string;
|
|
155
|
+
signature: string;
|
|
156
|
+
nonce: string;
|
|
157
|
+
};
|
|
158
|
+
export type LinkedWallet = {
|
|
159
|
+
address: string;
|
|
160
|
+
type: string;
|
|
161
|
+
created_at: string;
|
|
162
|
+
updated_at: string;
|
|
163
|
+
name?: string;
|
|
164
|
+
clientName: string;
|
|
165
|
+
};
|
|
166
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const hexToString: (hex: string) => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const mockValidIdToken: string;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export default class TypedEventEmitter<TEvents extends Record<string, any>> {
|
|
2
|
+
private emitter;
|
|
3
|
+
emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArg: TEvents[TEventName]): void;
|
|
4
|
+
on<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
|
|
5
|
+
removeListener<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
|
|
6
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ProviderErrors should take priority over RpcErrorCodes
|
|
3
|
+
* https://eips.ethereum.org/EIPS/eip-1193#provider-errors
|
|
4
|
+
* https://eips.ethereum.org/EIPS/eip-1474#error-codes
|
|
5
|
+
*/
|
|
6
|
+
export declare enum ProviderErrorCode {
|
|
7
|
+
USER_REJECTED_REQUEST = 4001,
|
|
8
|
+
UNAUTHORIZED = 4100,
|
|
9
|
+
UNSUPPORTED_METHOD = 4200,
|
|
10
|
+
DISCONNECTED = 4900
|
|
11
|
+
}
|
|
12
|
+
export declare enum RpcErrorCode {
|
|
13
|
+
RPC_SERVER_ERROR = -32000,
|
|
14
|
+
INVALID_REQUEST = -32600,
|
|
15
|
+
METHOD_NOT_FOUND = -32601,
|
|
16
|
+
INVALID_PARAMS = -32602,
|
|
17
|
+
INTERNAL_ERROR = -32603,
|
|
18
|
+
PARSE_ERROR = -32700,
|
|
19
|
+
TRANSACTION_REJECTED = -32003
|
|
20
|
+
}
|
|
21
|
+
export declare class JsonRpcError extends Error {
|
|
22
|
+
readonly message: string;
|
|
23
|
+
readonly code: ProviderErrorCode | RpcErrorCode;
|
|
24
|
+
constructor(code: ProviderErrorCode | RpcErrorCode, message: string);
|
|
25
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Flow } from '@imtbl/metrics';
|
|
2
|
+
import { Signer, JsonRpcProvider } from 'ethers';
|
|
3
|
+
import GuardianClient from '../guardian';
|
|
4
|
+
import { RelayerClient } from './relayerClient';
|
|
5
|
+
interface PersonalSignParams {
|
|
6
|
+
ethSigner: Signer;
|
|
7
|
+
rpcProvider: JsonRpcProvider;
|
|
8
|
+
params: any[];
|
|
9
|
+
zkEvmAddress: string;
|
|
10
|
+
guardianClient: GuardianClient;
|
|
11
|
+
relayerClient: RelayerClient;
|
|
12
|
+
flow: Flow;
|
|
13
|
+
}
|
|
14
|
+
export declare const personalSign: ({ params, ethSigner, zkEvmAddress, rpcProvider, guardianClient, relayerClient, flow, }: PersonalSignParams) => Promise<string>;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { BytesLike, JsonRpcProvider } from 'ethers';
|
|
2
|
+
import AuthManager from '../authManager';
|
|
3
|
+
import { PassportConfiguration } from '../config';
|
|
4
|
+
import { FeeOption, RelayerTransaction, TypedDataPayload } from './types';
|
|
5
|
+
export type RelayerClientInput = {
|
|
6
|
+
config: PassportConfiguration;
|
|
7
|
+
rpcProvider: JsonRpcProvider;
|
|
8
|
+
authManager: AuthManager;
|
|
9
|
+
};
|
|
10
|
+
type EthSendTransactionRequest = {
|
|
11
|
+
method: 'eth_sendTransaction';
|
|
12
|
+
params: {
|
|
13
|
+
to: string;
|
|
14
|
+
data: BytesLike;
|
|
15
|
+
chainId: string;
|
|
16
|
+
}[];
|
|
17
|
+
};
|
|
18
|
+
type ImGetTransactionByHashRequest = {
|
|
19
|
+
method: 'im_getTransactionByHash';
|
|
20
|
+
params: string[];
|
|
21
|
+
};
|
|
22
|
+
type ImGetFeeOptionsRequest = {
|
|
23
|
+
method: 'im_getFeeOptions';
|
|
24
|
+
params: {
|
|
25
|
+
userAddress: string;
|
|
26
|
+
data: BytesLike;
|
|
27
|
+
chainId: string;
|
|
28
|
+
}[];
|
|
29
|
+
};
|
|
30
|
+
type ImSignRequest = {
|
|
31
|
+
method: 'im_sign';
|
|
32
|
+
params: {
|
|
33
|
+
chainId: string;
|
|
34
|
+
address: string;
|
|
35
|
+
message: string;
|
|
36
|
+
}[];
|
|
37
|
+
};
|
|
38
|
+
type ImSignTypedDataRequest = {
|
|
39
|
+
method: 'im_signTypedData';
|
|
40
|
+
params: {
|
|
41
|
+
chainId: string;
|
|
42
|
+
address: string;
|
|
43
|
+
eip712Payload: TypedDataPayload;
|
|
44
|
+
}[];
|
|
45
|
+
};
|
|
46
|
+
export type RelayerTransactionRequest = EthSendTransactionRequest | ImGetTransactionByHashRequest | ImGetFeeOptionsRequest | ImSignTypedDataRequest | ImSignRequest;
|
|
47
|
+
export declare class RelayerClient {
|
|
48
|
+
private readonly config;
|
|
49
|
+
private readonly rpcProvider;
|
|
50
|
+
private readonly authManager;
|
|
51
|
+
constructor({ config, rpcProvider, authManager }: RelayerClientInput);
|
|
52
|
+
private postToRelayer;
|
|
53
|
+
ethSendTransaction(to: string, data: BytesLike): Promise<string>;
|
|
54
|
+
imGetTransactionByHash(hash: string): Promise<RelayerTransaction>;
|
|
55
|
+
imGetFeeOptions(userAddress: string, data: BytesLike): Promise<FeeOption[]>;
|
|
56
|
+
imSignTypedData(address: string, eip712Payload: TypedDataPayload): Promise<string>;
|
|
57
|
+
imSign(address: string, message: string): Promise<string>;
|
|
58
|
+
}
|
|
59
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { TransactionParams } from './transactionHelpers';
|
|
2
|
+
type EthSendDeployTransactionParams = TransactionParams & {
|
|
3
|
+
params: Array<any>;
|
|
4
|
+
};
|
|
5
|
+
export declare const sendDeployTransactionAndPersonalSign: ({ params, ethSigner, rpcProvider, relayerClient, guardianClient, zkEvmAddress, flow, }: EthSendDeployTransactionParams) => Promise<string>;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { TransactionParams } from './transactionHelpers';
|
|
2
|
+
type EthSendTransactionParams = TransactionParams & {
|
|
3
|
+
params: Array<any>;
|
|
4
|
+
};
|
|
5
|
+
export declare const sendTransaction: ({ params, ethSigner, rpcProvider, relayerClient, guardianClient, zkEvmAddress, flow, }: EthSendTransactionParams) => Promise<string>;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function errorBoundary<T extends (...args: any[]) => any>(fn: T, fallbackResult?: ReturnType<T>): (...args: Parameters<T>) => ReturnType<T>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Environment } from '@imtbl/config';
|
|
2
|
+
export declare const setupClient: (environment: Environment) => void;
|
|
3
|
+
type CheckParams = {
|
|
4
|
+
clientId: string;
|
|
5
|
+
wallet?: string;
|
|
6
|
+
checkCount?: number;
|
|
7
|
+
sendCount?: number;
|
|
8
|
+
};
|
|
9
|
+
export type CheckResponse = {
|
|
10
|
+
contractAddress?: string;
|
|
11
|
+
functionName?: string;
|
|
12
|
+
delay?: number;
|
|
13
|
+
};
|
|
14
|
+
export declare function get(queries: CheckParams): Promise<CheckResponse | undefined>;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { EjectionTransactionParams, EjectionTransactionResponse } from './transactionHelpers';
|
|
2
|
+
type EthSendTransactionEjectionParams = EjectionTransactionParams & {
|
|
3
|
+
params: Array<any>;
|
|
4
|
+
};
|
|
5
|
+
export declare const signEjectionTransaction: ({ params, ethSigner, zkEvmAddress, flow, }: EthSendTransactionEjectionParams) => Promise<EjectionTransactionResponse>;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Flow } from '@imtbl/metrics';
|
|
2
|
+
import { Signer, JsonRpcProvider } from 'ethers';
|
|
3
|
+
import GuardianClient from '../guardian';
|
|
4
|
+
import { RelayerClient } from './relayerClient';
|
|
5
|
+
export type SignTypedDataV4Params = {
|
|
6
|
+
ethSigner: Signer;
|
|
7
|
+
rpcProvider: JsonRpcProvider;
|
|
8
|
+
relayerClient: RelayerClient;
|
|
9
|
+
method: string;
|
|
10
|
+
params: Array<any>;
|
|
11
|
+
guardianClient: GuardianClient;
|
|
12
|
+
flow: Flow;
|
|
13
|
+
};
|
|
14
|
+
export declare const signTypedDataV4: ({ params, method, ethSigner, rpcProvider, relayerClient, guardianClient, flow, }: SignTypedDataV4Params) => Promise<string>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Flow } from '@imtbl/metrics';
|
|
2
|
+
import { Signer, TransactionRequest, JsonRpcProvider, BigNumberish } from 'ethers';
|
|
3
|
+
import { RelayerClient } from './relayerClient';
|
|
4
|
+
import GuardianClient from '../guardian';
|
|
5
|
+
export type TransactionParams = {
|
|
6
|
+
ethSigner: Signer;
|
|
7
|
+
rpcProvider: JsonRpcProvider;
|
|
8
|
+
guardianClient: GuardianClient;
|
|
9
|
+
relayerClient: RelayerClient;
|
|
10
|
+
zkEvmAddress: string;
|
|
11
|
+
flow: Flow;
|
|
12
|
+
};
|
|
13
|
+
export type EjectionTransactionParams = Pick<TransactionParams, 'ethSigner' | 'zkEvmAddress' | 'flow'>;
|
|
14
|
+
export type EjectionTransactionResponse = {
|
|
15
|
+
to: string;
|
|
16
|
+
data: string;
|
|
17
|
+
chainId: string;
|
|
18
|
+
};
|
|
19
|
+
export declare const pollRelayerTransaction: (relayerClient: RelayerClient, relayerId: string, flow: Flow) => Promise<import("./types").RelayerTransaction>;
|
|
20
|
+
export declare const prepareAndSignTransaction: ({ transactionRequest, ethSigner, rpcProvider, guardianClient, relayerClient, zkEvmAddress, flow, }: TransactionParams & {
|
|
21
|
+
transactionRequest: TransactionRequest;
|
|
22
|
+
}) => Promise<{
|
|
23
|
+
signedTransactions: string;
|
|
24
|
+
relayerId: string;
|
|
25
|
+
nonce: BigNumberish;
|
|
26
|
+
}>;
|
|
27
|
+
export declare const prepareAndSignEjectionTransaction: ({ transactionRequest, ethSigner, zkEvmAddress, flow, }: EjectionTransactionParams & {
|
|
28
|
+
transactionRequest: TransactionRequest;
|
|
29
|
+
}) => Promise<EjectionTransactionResponse>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { BigNumberish } from 'ethers';
|
|
2
|
+
import { JsonRpcError } from './JsonRpcError';
|
|
3
|
+
export declare enum RelayerTransactionStatus {
|
|
4
|
+
PENDING = "PENDING",
|
|
5
|
+
SUBMITTED = "SUBMITTED",
|
|
6
|
+
SUCCESSFUL = "SUCCESSFUL",
|
|
7
|
+
REVERTED = "REVERTED",
|
|
8
|
+
FAILED = "FAILED",
|
|
9
|
+
CANCELLED = "CANCELLED"
|
|
10
|
+
}
|
|
11
|
+
export interface RelayerTransaction {
|
|
12
|
+
status: RelayerTransactionStatus;
|
|
13
|
+
chainId: string;
|
|
14
|
+
relayerId: string;
|
|
15
|
+
hash: string;
|
|
16
|
+
statusMessage?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface FeeOption {
|
|
19
|
+
tokenPrice: string;
|
|
20
|
+
tokenSymbol: string;
|
|
21
|
+
tokenDecimals: number;
|
|
22
|
+
tokenAddress: string;
|
|
23
|
+
recipientAddress: string;
|
|
24
|
+
}
|
|
25
|
+
export interface MetaTransaction {
|
|
26
|
+
to: string;
|
|
27
|
+
value?: BigNumberish | null;
|
|
28
|
+
data?: string | null;
|
|
29
|
+
nonce?: BigNumberish | null;
|
|
30
|
+
gasLimit?: BigNumberish;
|
|
31
|
+
delegateCall?: boolean;
|
|
32
|
+
revertOnError?: boolean;
|
|
33
|
+
}
|
|
34
|
+
export interface MetaTransactionNormalised {
|
|
35
|
+
delegateCall: boolean;
|
|
36
|
+
revertOnError: boolean;
|
|
37
|
+
gasLimit: BigNumberish;
|
|
38
|
+
target: string;
|
|
39
|
+
value: BigNumberish;
|
|
40
|
+
data: string;
|
|
41
|
+
}
|
|
42
|
+
export interface TypedDataPayload {
|
|
43
|
+
types: {
|
|
44
|
+
EIP712Domain: Array<{
|
|
45
|
+
name: string;
|
|
46
|
+
type: string;
|
|
47
|
+
}>;
|
|
48
|
+
[key: string]: Array<{
|
|
49
|
+
name: string;
|
|
50
|
+
type: string;
|
|
51
|
+
}>;
|
|
52
|
+
};
|
|
53
|
+
domain: {
|
|
54
|
+
name?: string;
|
|
55
|
+
version?: string;
|
|
56
|
+
chainId?: string;
|
|
57
|
+
verifyingContract?: string;
|
|
58
|
+
salt?: string;
|
|
59
|
+
};
|
|
60
|
+
primaryType: string;
|
|
61
|
+
message: Record<string, any>;
|
|
62
|
+
}
|
|
63
|
+
export interface RequestArguments {
|
|
64
|
+
method: string;
|
|
65
|
+
params?: Array<any>;
|
|
66
|
+
}
|
|
67
|
+
export type JsonRpcRequestPayload = RequestArguments & {
|
|
68
|
+
jsonrpc?: string;
|
|
69
|
+
id?: string | number;
|
|
70
|
+
};
|
|
71
|
+
export interface JsonRpcRequestCallback {
|
|
72
|
+
(err: JsonRpcError | null, result?: JsonRpcResponsePayload | (JsonRpcResponsePayload | null)[] | null): void;
|
|
73
|
+
}
|
|
74
|
+
export interface JsonRpcResponsePayload {
|
|
75
|
+
result?: Array<any> | null;
|
|
76
|
+
error?: JsonRpcError | null;
|
|
77
|
+
jsonrpc?: string;
|
|
78
|
+
id?: string | number;
|
|
79
|
+
}
|
|
80
|
+
export type Provider = {
|
|
81
|
+
request: (request: RequestArguments) => Promise<any>;
|
|
82
|
+
on: (event: string, listener: (...args: any[]) => void) => void;
|
|
83
|
+
removeListener: (event: string, listener: (...args: any[]) => void) => void;
|
|
84
|
+
isPassport: boolean;
|
|
85
|
+
};
|
|
86
|
+
export declare enum ProviderEvent {
|
|
87
|
+
ACCOUNTS_CHANGED = "accountsChanged"
|
|
88
|
+
}
|
|
89
|
+
export type AccountsChangedEvent = Array<string>;
|
|
90
|
+
export interface ProviderEventMap extends Record<string, any> {
|
|
91
|
+
[ProviderEvent.ACCOUNTS_CHANGED]: [AccountsChangedEvent];
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Event detail from the `eip6963:announceProvider` event.
|
|
95
|
+
*/
|
|
96
|
+
export interface EIP6963ProviderDetail {
|
|
97
|
+
info: EIP6963ProviderInfo;
|
|
98
|
+
provider: Provider;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Metadata of the EIP-1193 Provider.
|
|
102
|
+
*/
|
|
103
|
+
export interface EIP6963ProviderInfo {
|
|
104
|
+
icon: `data:image/${string}`;
|
|
105
|
+
name: string;
|
|
106
|
+
rdns: string;
|
|
107
|
+
uuid: string;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Event type to announce an EIP-1193 Provider.
|
|
111
|
+
*/
|
|
112
|
+
export interface EIP6963AnnounceProviderEvent extends CustomEvent<EIP6963ProviderDetail> {
|
|
113
|
+
type: 'eip6963:announceProvider';
|
|
114
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './registerZkEvmUser';
|