@mocanetwork/airkit 1.8.0-beta.0 → 1.8.0-beta.2
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/dist/airkit.cjs.js +12 -4
- package/dist/airkit.esm.js +12 -4
- package/dist/airkit.umd.js +12 -4
- package/dist/types/airService.d.ts +9 -6
- package/dist/types/common/air/messaging/types.d.ts +2 -0
- package/dist/types/common/air/messaging/wallet.d.ts +11 -3
- package/dist/types/common/const.d.ts +28 -0
- package/dist/types/common/currency.d.ts +35 -0
- package/dist/types/common/types.d.ts +8 -0
- package/dist/types/interfaces.d.ts +9 -0
- package/dist/types/walletMessageService.d.ts +5 -3
- package/package.json +1 -1
package/dist/airkit.cjs.js
CHANGED
|
@@ -97,7 +97,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
97
97
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
98
98
|
};
|
|
99
99
|
|
|
100
|
-
var version = "1.8.0-beta.
|
|
100
|
+
var version = "1.8.0-beta.2";
|
|
101
101
|
var airkitPackage = {
|
|
102
102
|
version: version};
|
|
103
103
|
|
|
@@ -2497,7 +2497,12 @@ class WalletMessageService extends MessageServiceBase {
|
|
|
2497
2497
|
const response = firstValueFrom(this.messages$.pipe(filter((msg) => msg.type === AirWalletMessageTypes.SHOW_SWAP_UI_RESPONSE)));
|
|
2498
2498
|
await this.sendMessage({
|
|
2499
2499
|
type: AirWalletMessageTypes.SHOW_SWAP_UI_REQUEST,
|
|
2500
|
-
payload
|
|
2500
|
+
payload: {
|
|
2501
|
+
initialFromToken: payload?.initialFromToken,
|
|
2502
|
+
fallbackFromToken: payload?.fallbackFromToken,
|
|
2503
|
+
initialToToken: payload?.initialToToken,
|
|
2504
|
+
defaultSlippage: payload?.defaultSlippage?.toString(), // TODO refactor to all be numbers
|
|
2505
|
+
},
|
|
2501
2506
|
});
|
|
2502
2507
|
return response;
|
|
2503
2508
|
}
|
|
@@ -2956,7 +2961,7 @@ class AirService {
|
|
|
2956
2961
|
if (result.payload.success === false) {
|
|
2957
2962
|
throw new AirServiceError(result.payload.errorName, result.payload.errorMessage);
|
|
2958
2963
|
}
|
|
2959
|
-
return
|
|
2964
|
+
return result.payload;
|
|
2960
2965
|
}
|
|
2961
2966
|
/**
|
|
2962
2967
|
* @experimental This feature has not been officially released and might change in the future.
|
|
@@ -3011,7 +3016,10 @@ class AirService {
|
|
|
3011
3016
|
throw new AirServiceError(result.payload.errorName, result.payload.errorMessage);
|
|
3012
3017
|
}
|
|
3013
3018
|
}
|
|
3014
|
-
const sessionConfig = {
|
|
3019
|
+
const sessionConfig = {
|
|
3020
|
+
locale: results[0].payload.locale,
|
|
3021
|
+
currency: results[0].payload.currency,
|
|
3022
|
+
};
|
|
3015
3023
|
__classPrivateFieldSet(this, _AirService_sessionConfig, sessionConfig, "f");
|
|
3016
3024
|
return sessionConfig;
|
|
3017
3025
|
}
|
package/dist/airkit.esm.js
CHANGED
|
@@ -95,7 +95,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
95
95
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
96
96
|
};
|
|
97
97
|
|
|
98
|
-
var version = "1.8.0-beta.
|
|
98
|
+
var version = "1.8.0-beta.2";
|
|
99
99
|
var airkitPackage = {
|
|
100
100
|
version: version};
|
|
101
101
|
|
|
@@ -2495,7 +2495,12 @@ class WalletMessageService extends MessageServiceBase {
|
|
|
2495
2495
|
const response = firstValueFrom(this.messages$.pipe(filter((msg) => msg.type === AirWalletMessageTypes.SHOW_SWAP_UI_RESPONSE)));
|
|
2496
2496
|
await this.sendMessage({
|
|
2497
2497
|
type: AirWalletMessageTypes.SHOW_SWAP_UI_REQUEST,
|
|
2498
|
-
payload
|
|
2498
|
+
payload: {
|
|
2499
|
+
initialFromToken: payload?.initialFromToken,
|
|
2500
|
+
fallbackFromToken: payload?.fallbackFromToken,
|
|
2501
|
+
initialToToken: payload?.initialToToken,
|
|
2502
|
+
defaultSlippage: payload?.defaultSlippage?.toString(), // TODO refactor to all be numbers
|
|
2503
|
+
},
|
|
2499
2504
|
});
|
|
2500
2505
|
return response;
|
|
2501
2506
|
}
|
|
@@ -2954,7 +2959,7 @@ class AirService {
|
|
|
2954
2959
|
if (result.payload.success === false) {
|
|
2955
2960
|
throw new AirServiceError(result.payload.errorName, result.payload.errorMessage);
|
|
2956
2961
|
}
|
|
2957
|
-
return
|
|
2962
|
+
return result.payload;
|
|
2958
2963
|
}
|
|
2959
2964
|
/**
|
|
2960
2965
|
* @experimental This feature has not been officially released and might change in the future.
|
|
@@ -3009,7 +3014,10 @@ class AirService {
|
|
|
3009
3014
|
throw new AirServiceError(result.payload.errorName, result.payload.errorMessage);
|
|
3010
3015
|
}
|
|
3011
3016
|
}
|
|
3012
|
-
const sessionConfig = {
|
|
3017
|
+
const sessionConfig = {
|
|
3018
|
+
locale: results[0].payload.locale,
|
|
3019
|
+
currency: results[0].payload.currency,
|
|
3020
|
+
};
|
|
3013
3021
|
__classPrivateFieldSet(this, _AirService_sessionConfig, sessionConfig, "f");
|
|
3014
3022
|
return sessionConfig;
|
|
3015
3023
|
}
|
package/dist/airkit.umd.js
CHANGED
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
102
102
|
};
|
|
103
103
|
|
|
104
|
-
var version = "1.8.0-beta.
|
|
104
|
+
var version = "1.8.0-beta.2";
|
|
105
105
|
var airkitPackage = {
|
|
106
106
|
version: version};
|
|
107
107
|
|
|
@@ -2501,7 +2501,12 @@
|
|
|
2501
2501
|
const response = firstValueFrom(this.messages$.pipe(filter((msg) => msg.type === AirWalletMessageTypes.SHOW_SWAP_UI_RESPONSE)));
|
|
2502
2502
|
await this.sendMessage({
|
|
2503
2503
|
type: AirWalletMessageTypes.SHOW_SWAP_UI_REQUEST,
|
|
2504
|
-
payload
|
|
2504
|
+
payload: {
|
|
2505
|
+
initialFromToken: payload?.initialFromToken,
|
|
2506
|
+
fallbackFromToken: payload?.fallbackFromToken,
|
|
2507
|
+
initialToToken: payload?.initialToToken,
|
|
2508
|
+
defaultSlippage: payload?.defaultSlippage?.toString(), // TODO refactor to all be numbers
|
|
2509
|
+
},
|
|
2505
2510
|
});
|
|
2506
2511
|
return response;
|
|
2507
2512
|
}
|
|
@@ -2960,7 +2965,7 @@
|
|
|
2960
2965
|
if (result.payload.success === false) {
|
|
2961
2966
|
throw new AirServiceError(result.payload.errorName, result.payload.errorMessage);
|
|
2962
2967
|
}
|
|
2963
|
-
return
|
|
2968
|
+
return result.payload;
|
|
2964
2969
|
}
|
|
2965
2970
|
/**
|
|
2966
2971
|
* @experimental This feature has not been officially released and might change in the future.
|
|
@@ -3015,7 +3020,10 @@
|
|
|
3015
3020
|
throw new AirServiceError(result.payload.errorName, result.payload.errorMessage);
|
|
3016
3021
|
}
|
|
3017
3022
|
}
|
|
3018
|
-
const sessionConfig = {
|
|
3023
|
+
const sessionConfig = {
|
|
3024
|
+
locale: results[0].payload.locale,
|
|
3025
|
+
currency: results[0].payload.currency,
|
|
3026
|
+
};
|
|
3019
3027
|
__classPrivateFieldSet(this, _AirService_sessionConfig, sessionConfig, "f");
|
|
3020
3028
|
return sessionConfig;
|
|
3021
3029
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AirAuthStartRecoveryRequestPayload } from "@mocanetwork/common/src/air/messaging/auth";
|
|
2
|
-
import { AirEventListener, AirLoginResult, AirSessionConfig, AirUserDetails, BUILD_ENV, BUILD_ENV_TYPE, ClaimAirIdOptions, ClaimAirIdResult, CredentialNetwork, CredentialVerificationResult, EIP1193Provider } from "./interfaces";
|
|
2
|
+
import { AirEventListener, AirLoginResult, AirSessionConfig, AirUserDetails, BUILD_ENV, BUILD_ENV_TYPE, ClaimAirIdOptions, ClaimAirIdResult, CredentialNetwork, CredentialVerificationResult, EIP1193Provider, ShowSwapUIOptions } from "./interfaces";
|
|
3
|
+
import { Token } from "packages/common/src/types";
|
|
3
4
|
declare class AirService {
|
|
4
5
|
#private;
|
|
5
6
|
constructor({ partnerId }: {
|
|
@@ -48,12 +49,14 @@ declare class AirService {
|
|
|
48
49
|
/**
|
|
49
50
|
* @experimental This feature has not been officially released and might change in the future.
|
|
50
51
|
*/
|
|
51
|
-
showSwapUI(options?: {
|
|
52
|
-
initialFromToken?: string;
|
|
53
|
-
fallbackFromToken?: string;
|
|
54
|
-
initialToToken?: string;
|
|
55
|
-
}): Promise<{
|
|
52
|
+
showSwapUI(options?: ShowSwapUIOptions): Promise<{
|
|
56
53
|
txHash: `0x${string}`;
|
|
54
|
+
from: Token & {
|
|
55
|
+
amount: string;
|
|
56
|
+
};
|
|
57
|
+
to: Token & {
|
|
58
|
+
amount: string;
|
|
59
|
+
};
|
|
57
60
|
}>;
|
|
58
61
|
/**
|
|
59
62
|
* @experimental This feature has not been officially released and might change in the future.
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SupportedCurrencyCode } from "../../currency";
|
|
1
2
|
import { AirErrorName } from "../error/types";
|
|
2
3
|
export type AirMessageBase<TType extends string = string, TPayload extends object = object> = {
|
|
3
4
|
type: TType;
|
|
@@ -16,4 +17,5 @@ export type AirMessageErrorPayload = {
|
|
|
16
17
|
};
|
|
17
18
|
export type SessionConfig = {
|
|
18
19
|
locale: string;
|
|
20
|
+
currency: SupportedCurrencyCode;
|
|
19
21
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { TokenSymbol, Token } from "../../types";
|
|
1
2
|
import { AirIdDetails, MFASetup } from "../../realm/user/types";
|
|
2
3
|
import { AirWalletProviderMessageErrorResponse, AirWalletProviderMessageRequest, AirWalletProviderMessageSuccessResponse } from "./provider";
|
|
3
4
|
import { AirMessageBase, AirMessageBaseWithoutPayload, AirMessageErrorPayload, AirMessageSuccessPayload, SessionConfig } from "./types";
|
|
@@ -76,12 +77,19 @@ export type AirClaimIdSuccess = AirMessageSuccessPayload & {
|
|
|
76
77
|
export type AirClaimIdResponsePayload = AirClaimIdSuccess | AirMessageErrorPayload;
|
|
77
78
|
export type AirClaimIdResponseMessage = AirWalletMessageBase<"air_claim_id_response", AirClaimIdResponsePayload>;
|
|
78
79
|
export type AirShowSwapUIRequestMessage = AirWalletMessageBase<"air_show_swap_ui_request", {
|
|
79
|
-
initialFromToken?:
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
initialFromToken?: TokenSymbol;
|
|
81
|
+
initialToToken?: TokenSymbol;
|
|
82
|
+
fallbackFromToken?: TokenSymbol;
|
|
83
|
+
defaultSlippage?: string;
|
|
82
84
|
}>;
|
|
83
85
|
export type AirShowSwapUISuccess = AirMessageSuccessPayload & {
|
|
84
86
|
txHash: `0x${string}`;
|
|
87
|
+
from: Token & {
|
|
88
|
+
amount: string;
|
|
89
|
+
};
|
|
90
|
+
to: Token & {
|
|
91
|
+
amount: string;
|
|
92
|
+
};
|
|
85
93
|
};
|
|
86
94
|
export type AirShowSwapUIResponseMessage = AirWalletMessageBase<"air_show_swap_ui_response", AirShowSwapUISuccess | AirMessageErrorPayload>;
|
|
87
95
|
export type AirShowOnRampUIRequestMessage = AirWalletMessageBase<"air_show_on_ramp_ui_request", {
|
|
@@ -54,3 +54,31 @@ export declare const mocaTestnet: {
|
|
|
54
54
|
};
|
|
55
55
|
readonly testnet: true;
|
|
56
56
|
};
|
|
57
|
+
export declare const mocaMainnet: {
|
|
58
|
+
readonly id: 2288;
|
|
59
|
+
readonly name: "Moca Mainnet";
|
|
60
|
+
readonly nativeCurrency: {
|
|
61
|
+
readonly decimals: 18;
|
|
62
|
+
readonly name: "Moca Network";
|
|
63
|
+
readonly symbol: "MOCA";
|
|
64
|
+
};
|
|
65
|
+
readonly rpcUrls: {
|
|
66
|
+
readonly default: {
|
|
67
|
+
readonly http: readonly ["https://rpc.mocachain.org"];
|
|
68
|
+
readonly webSocket: readonly ["wss://rpc.mocachain.org/ws"];
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
readonly blockExplorers: {
|
|
72
|
+
readonly default: {
|
|
73
|
+
readonly name: "Moca Mainnet";
|
|
74
|
+
readonly url: "https://scan.mocachain.org";
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
readonly contracts: {
|
|
78
|
+
readonly multicall3: {
|
|
79
|
+
readonly address: "0xcA11bde05977b3631167028862bE2a173976CA11";
|
|
80
|
+
readonly blockCreated: 1;
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
readonly testnet: false;
|
|
84
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Supported fiat currency codes
|
|
3
|
+
* Use these typed constants instead of raw strings for better type safety
|
|
4
|
+
*/
|
|
5
|
+
export declare const SUPPORTED_CURRENCY_CODES: {
|
|
6
|
+
readonly EUR: "EUR";
|
|
7
|
+
readonly USD: "USD";
|
|
8
|
+
readonly CNY: "CNY";
|
|
9
|
+
readonly KRW: "KRW";
|
|
10
|
+
readonly TRY: "TRY";
|
|
11
|
+
};
|
|
12
|
+
export type SupportedCurrencyCode = (typeof SUPPORTED_CURRENCY_CODES)[keyof typeof SUPPORTED_CURRENCY_CODES];
|
|
13
|
+
/**
|
|
14
|
+
* Default currency code (USD)
|
|
15
|
+
*/
|
|
16
|
+
export declare const DEFAULT_CURRENCY_CODE: "USD";
|
|
17
|
+
/**
|
|
18
|
+
* Currency information including symbol, decimals, and localized names
|
|
19
|
+
*/
|
|
20
|
+
export type CurrencyInfo = {
|
|
21
|
+
readonly type: 'fiat';
|
|
22
|
+
readonly code: SupportedCurrencyCode;
|
|
23
|
+
readonly symbol: string;
|
|
24
|
+
readonly name: {
|
|
25
|
+
readonly [key: string]: string;
|
|
26
|
+
};
|
|
27
|
+
readonly decimals: number;
|
|
28
|
+
readonly floatingPoint: number;
|
|
29
|
+
readonly image: string;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Supported fiat currencies with full metadata
|
|
33
|
+
* This is the source of truth for all supported currencies
|
|
34
|
+
*/
|
|
35
|
+
export declare const SUPPORTED_CURRENCIES: readonly CurrencyInfo[];
|
|
@@ -12,3 +12,11 @@ export type IntersectionToUnion<T> = {
|
|
|
12
12
|
[K in keyof T]: (x: T[K]) => void;
|
|
13
13
|
}[keyof T] extends (x: infer U) => void ? U : never;
|
|
14
14
|
export type FixedArray<T, N extends number, Acc extends T[] = []> = Acc["length"] extends N ? Acc : FixedArray<T, N, [...Acc, T]>;
|
|
15
|
+
export type TokenSymbol = {
|
|
16
|
+
symbol: string;
|
|
17
|
+
chainId: number;
|
|
18
|
+
};
|
|
19
|
+
export type Token = TokenSymbol & {
|
|
20
|
+
decimals: number;
|
|
21
|
+
address: `0x${string}`;
|
|
22
|
+
};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { AirVerifyCredentialSuccessResponsePayload } from "@mocanetwork/common/src/air/messaging/credential";
|
|
2
2
|
import { mocaDevnet, mocaTestnet } from "@mocanetwork/common/src/const";
|
|
3
|
+
import { SupportedCurrencyCode } from "@mocanetwork/common/src/currency";
|
|
3
4
|
import { EIP1193Provider as EIP1193ProviderInterface } from "./common/provider/types";
|
|
4
5
|
import { AirIdDetails } from "./common/realm/user/types";
|
|
6
|
+
import { TokenSymbol } from "packages/common/src/types";
|
|
5
7
|
export declare const BUILD_ENV: {
|
|
6
8
|
readonly PRODUCTION: "production";
|
|
7
9
|
readonly UAT: "uat";
|
|
@@ -34,6 +36,7 @@ export type AirUserDetails = {
|
|
|
34
36
|
};
|
|
35
37
|
export type AirSessionConfig = {
|
|
36
38
|
locale: string;
|
|
39
|
+
currency: SupportedCurrencyCode;
|
|
37
40
|
};
|
|
38
41
|
export type CredentialNetwork = "devnet" | "testnet";
|
|
39
42
|
export type AirLoginResult = {
|
|
@@ -77,5 +80,11 @@ export type ClaimAirIdOptions = {
|
|
|
77
80
|
background: true;
|
|
78
81
|
offchain?: boolean;
|
|
79
82
|
};
|
|
83
|
+
export type ShowSwapUIOptions = {
|
|
84
|
+
initialFromToken?: TokenSymbol;
|
|
85
|
+
fallbackFromToken?: TokenSymbol;
|
|
86
|
+
initialToToken?: TokenSymbol;
|
|
87
|
+
defaultSlippage?: number;
|
|
88
|
+
};
|
|
80
89
|
export type EIP1193Provider = EIP1193ProviderInterface;
|
|
81
90
|
export { mocaDevnet, mocaTestnet };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AirWindowMessage } from "@mocanetwork/common/src/air/messaging/window";
|
|
2
|
+
import { TokenSymbol } from "@mocanetwork/common/src/types";
|
|
2
3
|
import { MessageServiceBase } from "./common/air/messaging/messageServiceBase";
|
|
3
4
|
import { AirClaimIdRequestMessage, AirInitializationRequestMessage, AirWalletMessage, AirWalletUpdateSessionConfigRequestMessage } from "./common/air/messaging/wallet";
|
|
4
5
|
export declare class WalletMessageService extends MessageServiceBase<AirWalletMessage | AirWindowMessage> {
|
|
@@ -19,9 +20,10 @@ export declare class WalletMessageService extends MessageServiceBase<AirWalletMe
|
|
|
19
20
|
sendWindowClosed(windowId: string): Promise<void>;
|
|
20
21
|
sendClaimIdRequest(payload: AirClaimIdRequestMessage["payload"]): Promise<import("./common/air/messaging/wallet").AirClaimIdResponseMessage>;
|
|
21
22
|
sendShowSwapUIRequest(payload?: {
|
|
22
|
-
initialFromToken?:
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
initialFromToken?: TokenSymbol;
|
|
24
|
+
initialToToken?: TokenSymbol;
|
|
25
|
+
fallbackFromToken?: TokenSymbol;
|
|
26
|
+
defaultSlippage?: number;
|
|
25
27
|
}): Promise<import("./common/air/messaging/wallet").AirShowSwapUIResponseMessage>;
|
|
26
28
|
sendShowOnRampUIRequest(payload: {
|
|
27
29
|
displayCurrencyCode: string;
|