@ultraos/wallet-sdk 0.0.3 → 0.0.5
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/package.json +4 -3
- package/src/index.d.ts +3 -0
- package/src/index.d.ts.map +1 -0
- package/src/{index.ts → index.js} +1 -0
- package/src/index.js.map +1 -0
- package/src/lib/common/client-error.d.ts +8 -0
- package/src/lib/common/client-error.d.ts.map +1 -0
- package/src/lib/common/client-error.js +11 -0
- package/src/lib/common/client-error.js.map +1 -0
- package/src/lib/common/client-messenger.d.ts +10 -0
- package/src/lib/common/client-messenger.d.ts.map +1 -0
- package/src/lib/common/client-messenger.js +93 -0
- package/src/lib/common/client-messenger.js.map +1 -0
- package/src/lib/common/window-manager.d.ts +9 -0
- package/src/lib/common/window-manager.d.ts.map +1 -0
- package/src/lib/common/window-manager.js +25 -0
- package/src/lib/common/window-manager.js.map +1 -0
- package/src/lib/config/ultra-wallet-sdk.config.d.ts +16 -0
- package/src/lib/config/ultra-wallet-sdk.config.d.ts.map +1 -0
- package/src/lib/config/ultra-wallet-sdk.config.js +20 -0
- package/src/lib/config/ultra-wallet-sdk.config.js.map +1 -0
- package/src/lib/interfaces/blockchain-transaction.interface.d.ts +22 -0
- package/src/lib/interfaces/blockchain-transaction.interface.d.ts.map +1 -0
- package/src/lib/interfaces/blockchain-transaction.interface.js +2 -0
- package/src/lib/interfaces/blockchain-transaction.interface.js.map +1 -0
- package/src/lib/interfaces/connect-params.interface.d.ts +14 -0
- package/src/lib/interfaces/connect-params.interface.d.ts.map +1 -0
- package/src/lib/interfaces/connect-params.interface.js +2 -0
- package/src/lib/interfaces/connect-params.interface.js.map +1 -0
- package/src/lib/interfaces/error-enum.d.ts +11 -0
- package/src/lib/interfaces/error-enum.d.ts.map +1 -0
- package/src/lib/interfaces/error-enum.js +16 -0
- package/src/lib/interfaces/error-enum.js.map +1 -0
- package/src/lib/interfaces/index.d.ts +9 -0
- package/src/lib/interfaces/index.d.ts.map +1 -0
- package/src/lib/interfaces/{index.ts → index.js} +1 -0
- package/src/lib/interfaces/index.js.map +1 -0
- package/src/lib/interfaces/json-rpc-message.interface.d.ts +8 -0
- package/src/lib/interfaces/json-rpc-message.interface.d.ts.map +1 -0
- package/src/lib/interfaces/json-rpc-message.interface.js +2 -0
- package/src/lib/interfaces/json-rpc-message.interface.js.map +1 -0
- package/src/lib/interfaces/purchase-item.interface.d.ts +8 -0
- package/src/lib/interfaces/purchase-item.interface.d.ts.map +1 -0
- package/src/lib/interfaces/purchase-item.interface.js +9 -0
- package/src/lib/interfaces/purchase-item.interface.js.map +1 -0
- package/src/lib/interfaces/wallet-provider-response.interface.d.ts +150 -0
- package/src/lib/interfaces/wallet-provider-response.interface.d.ts.map +1 -0
- package/src/lib/interfaces/wallet-provider-response.interface.js +10 -0
- package/src/lib/interfaces/wallet-provider-response.interface.js.map +1 -0
- package/src/lib/interfaces/wallet-provider.interface.d.ts +41 -0
- package/src/lib/interfaces/wallet-provider.interface.d.ts.map +1 -0
- package/src/lib/interfaces/wallet-provider.interface.js +2 -0
- package/src/lib/interfaces/wallet-provider.interface.js.map +1 -0
- package/src/lib/interfaces/{wallet-sdk-options.interface.ts → wallet-sdk-options.interface.d.ts} +2 -1
- package/src/lib/interfaces/wallet-sdk-options.interface.d.ts.map +1 -0
- package/src/lib/interfaces/wallet-sdk-options.interface.js +2 -0
- package/src/lib/interfaces/wallet-sdk-options.interface.js.map +1 -0
- package/src/lib/providers/extension-provider/extension.provider.d.ts +17 -0
- package/src/lib/providers/extension-provider/extension.provider.d.ts.map +1 -0
- package/src/lib/providers/extension-provider/extension.provider.js +29 -0
- package/src/lib/providers/extension-provider/extension.provider.js.map +1 -0
- package/src/lib/providers/index.d.ts +3 -0
- package/src/lib/providers/index.d.ts.map +1 -0
- package/src/lib/providers/{index.ts → index.js} +1 -0
- package/src/lib/providers/index.js.map +1 -0
- package/src/lib/providers/web-provider/web.provider.d.ts +15 -0
- package/src/lib/providers/web-provider/web.provider.d.ts.map +1 -0
- package/src/lib/providers/web-provider/web.provider.js +36 -0
- package/src/lib/providers/web-provider/web.provider.js.map +1 -0
- package/src/lib/ultra-wallet-sdk.d.ts +25 -0
- package/src/lib/ultra-wallet-sdk.d.ts.map +1 -0
- package/src/lib/ultra-wallet-sdk.js +46 -0
- package/src/lib/ultra-wallet-sdk.js.map +1 -0
- package/src/lib/utils/chain-validator.d.ts +2 -0
- package/src/lib/utils/chain-validator.d.ts.map +1 -0
- package/src/lib/utils/chain-validator.js +6 -0
- package/src/lib/utils/chain-validator.js.map +1 -0
- package/src/lib/utils/detection.d.ts +2 -0
- package/src/lib/utils/detection.d.ts.map +1 -0
- package/src/lib/utils/detection.js +4 -0
- package/src/lib/utils/detection.js.map +1 -0
- package/LICENSE +0 -165
- package/README.md +0 -74
- package/eslint.config.js +0 -5
- package/jest.config.ts +0 -11
- package/karma.conf.js +0 -16
- package/project.json +0 -33
- package/src/lib/common/client-error.ts +0 -14
- package/src/lib/common/client-messenger.spec.ts +0 -118
- package/src/lib/common/client-messenger.ts +0 -109
- package/src/lib/common/window-manager.spec.ts +0 -65
- package/src/lib/common/window-manager.ts +0 -34
- package/src/lib/config/ultra-wallet-sdk.config.ts +0 -37
- package/src/lib/interfaces/blockchain-transaction.interface.ts +0 -21
- package/src/lib/interfaces/connect-params.interface.ts +0 -13
- package/src/lib/interfaces/error-enum.ts +0 -15
- package/src/lib/interfaces/json-rpc-message.interface.ts +0 -7
- package/src/lib/interfaces/purchase-item.interface.ts +0 -7
- package/src/lib/interfaces/wallet-provider-response.interface.ts +0 -157
- package/src/lib/interfaces/wallet-provider.interface.ts +0 -55
- package/src/lib/providers/extension-provider/extension.provider.spec.ts +0 -121
- package/src/lib/providers/extension-provider/extension.provider.ts +0 -55
- package/src/lib/providers/web-provider/web.provider.spec.ts +0 -76
- package/src/lib/providers/web-provider/web.provider.ts +0 -59
- package/src/lib/ultra-wallet-sdk.spec.ts +0 -90
- package/src/lib/ultra-wallet-sdk.ts +0 -67
- package/src/lib/utils/chain-validator.ts +0 -6
- package/src/lib/utils/detection.ts +0 -3
- package/tsconfig.json +0 -28
- package/tsconfig.lib.json +0 -12
- package/tsconfig.lib.prod.json +0 -9
- package/tsconfig.spec.json +0 -8
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enumeration of possible response statuses returned by the Ultra Wallet SDK.
|
|
3
|
+
*/
|
|
4
|
+
export var ResponseStatus;
|
|
5
|
+
(function (ResponseStatus) {
|
|
6
|
+
ResponseStatus["SUCCESS"] = "success";
|
|
7
|
+
ResponseStatus["FAIL"] = "fail";
|
|
8
|
+
ResponseStatus["ERROR"] = "error";
|
|
9
|
+
})(ResponseStatus || (ResponseStatus = {}));
|
|
10
|
+
//# sourceMappingURL=wallet-provider-response.interface.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wallet-provider-response.interface.js","sourceRoot":"","sources":["../../../../../../libs/wallet-sdk/src/lib/interfaces/wallet-provider-response.interface.ts"],"names":[],"mappings":"AAyBA;;GAEG;AACH,MAAM,CAAN,IAAY,cAIX;AAJD,WAAY,cAAc;IACxB,qCAAmB,CAAA;IACnB,+BAAa,CAAA;IACb,iCAAe,CAAA;AACjB,CAAC,EAJW,cAAc,KAAd,cAAc,QAIzB","sourcesContent":["/**\n * A generic wrapper for all Ultra Wallet SDK responses.\n * Encapsulates the status, data payload, and optional error messaging or codes.\n *\n * @template T The type of the data payload contained in the response.\n */\nexport interface UltraResponse<T = any> {\n /**\n * The status of the response, e.g., success, fail, or error.\n */\n status: ResponseStatus;\n /**\n * The actual response data payload.\n */\n data: T;\n /**\n * Optional end-user-readable message, explaining what went wrong (if applicable).\n */\n message?: string;\n /**\n * Optional error or status code.\n */\n code?: number;\n}\n\n/**\n * Enumeration of possible response statuses returned by the Ultra Wallet SDK.\n */\nexport enum ResponseStatus {\n SUCCESS = 'success',\n FAIL = 'fail',\n ERROR = 'error',\n}\n\n/**\n * Represents the result of a disconnect request.\n * A boolean indicating whether the disconnection was successful.\n */\nexport type DisconnectResponse = boolean;\n\n/**\n * Represents the result of a successful connection request, containing the user's account details.\n */\nexport type ConnectResult = Array<{\n /**\n * The blockchain network identifier.\n */\n blockchainid: string;\n /**\n * The public key associated with the user's account.\n */\n publicKey: string;\n}>;\n\n/**\n * The result structure returned after a successful item purchase using the Ultra Wallet.\n * Contains metadata about the purchased items and the associated blockchain transaction.\n */\nexport interface PurchaseItemResult {\n /**\n * An ID associated with the purchase order, used for support requests if required.\n */\n orderHash: string;\n\n items: {\n /**\n * The ID of the minted Uniq.\n */\n artifactId: string;\n /**\n * The purchased item ID.\n */\n productId: string;\n /**\n * The ID of the transaction in the blockchain, useful for tracking the status and details of the transaction.\n */\n blockchainTransactionId: string;\n }[];\n}\n\n/**\n * Represents the result returned after signing a message with the Ultra Wallet.\n */\nexport interface SignMessageResult {\n signature: string;\n}\n\n/**\n * Represents the result returned after signing a blockchain transaction with the Ultra Wallet.\n */\nexport interface SignTransactionResult {\n /**\n * The hash of the signed blockchain transaction.\n */\n transactionHash?: string;\n processed?: {\n id: string;\n block_num: number;\n block_time: string; // ISO timestamp\n producer_block_id: string | null;\n receipt: {\n status: string;\n cpu_usage_us: number;\n net_usage_words: number;\n };\n elapsed: number;\n net_usage: number;\n scheduled: boolean;\n action_traces: ActionTrace[];\n account_ram_delta: any | null;\n except: any | null;\n error_code: number | null;\n };\n}\n\nexport interface ActionTrace {\n action_ordinal: number;\n creator_action_ordinal: number;\n closest_unnotified_ancestor_action_ordinal: number;\n receipt: {\n receiver: string;\n act_digest: string;\n global_sequence: number;\n recv_sequence: number;\n auth_sequence: [string, number][];\n code_sequence: number;\n abi_sequence: number;\n };\n receiver: string;\n act: {\n account: string;\n name: string;\n authorization: {\n actor: string;\n permission: string;\n }[];\n data: {\n from: string;\n to: string;\n quantity: string;\n memo: string;\n };\n hex_data: string;\n };\n context_free: boolean;\n elapsed: number;\n console: string;\n trx_id: string;\n block_num: number;\n block_time: string;\n producer_block_id: string | null;\n account_ram_deltas: any[];\n except: any | null;\n error_code: number | null;\n return_value_hex_data: string;\n inline_traces: ActionTrace[];\n}\n"]}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { BlockchainTransaction } from './blockchain-transaction.interface';
|
|
2
|
+
import { ConnectParams } from './connect-params.interface';
|
|
3
|
+
import { PurchaseItemType } from './purchase-item.interface';
|
|
4
|
+
import { ConnectResult, DisconnectResponse, PurchaseItemResult, SignMessageResult, SignTransactionResult, UltraResponse } from './wallet-provider-response.interface';
|
|
5
|
+
/**
|
|
6
|
+
* Defines the minimal interface that a wallet provider must implement for the Ultra Wallet SDK.
|
|
7
|
+
*/
|
|
8
|
+
export interface UltraWalletProvider {
|
|
9
|
+
/**
|
|
10
|
+
* Prompt the user for permission to share his wallet info with the 3rd party application.
|
|
11
|
+
* Once permission is established the first time, the 3rd party application will be whitelisted for future requests.
|
|
12
|
+
* @param params.onlyIfTrusted - Do not prompt the user for permissions. Share current account info if Dapp is already trusted,
|
|
13
|
+
* otherwise rejects the request.
|
|
14
|
+
*/
|
|
15
|
+
connect(params?: ConnectParams): Promise<UltraResponse<ConnectResult>>;
|
|
16
|
+
/**
|
|
17
|
+
* Remove permission to interact with the 3rd party application
|
|
18
|
+
*/
|
|
19
|
+
disconnect(): Promise<UltraResponse<DisconnectResponse>>;
|
|
20
|
+
/**
|
|
21
|
+
* Open a popup to sign a message
|
|
22
|
+
* @param message - The message to sign. The message should be prefixed with "0x:, UOSx:, or message:"
|
|
23
|
+
*/
|
|
24
|
+
signMessage(message: string): Promise<UltraResponse<SignMessageResult>>;
|
|
25
|
+
/**
|
|
26
|
+
* Open a popup to sign a transaction
|
|
27
|
+
* @param transaction - The transaction to sign
|
|
28
|
+
*/
|
|
29
|
+
signTransaction(transaction: BlockchainTransaction | BlockchainTransaction[]): Promise<UltraResponse<SignTransactionResult>>;
|
|
30
|
+
/**
|
|
31
|
+
* Get current chain id
|
|
32
|
+
*/
|
|
33
|
+
getChainId(): Promise<UltraResponse<string>>;
|
|
34
|
+
/**
|
|
35
|
+
* Open a popup to purchase an item
|
|
36
|
+
* @param {PurchaseItemType} itemType - The type of item to purchase
|
|
37
|
+
* @param {string} itemId - The id of the item to purchase
|
|
38
|
+
*/
|
|
39
|
+
purchaseItem(itemType: PurchaseItemType, itemId: string): Promise<UltraResponse<PurchaseItemResult>>;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=wallet-provider.interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wallet-provider.interface.d.ts","sourceRoot":"","sources":["../../../../../../libs/wallet-sdk/src/lib/interfaces/wallet-provider.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,qBAAqB,EACrB,aAAa,EACd,MAAM,sCAAsC,CAAC;AAE9C;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;;;OAKG;IACH,OAAO,CAAC,MAAM,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC,CAAC;IAEvE;;OAEG;IACH,UAAU,IAAI,OAAO,CAAC,aAAa,CAAC,kBAAkB,CAAC,CAAC,CAAC;IAEzD;;;OAGG;IACH,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,iBAAiB,CAAC,CAAC,CAAC;IAExE;;;OAGG;IACH,eAAe,CACb,WAAW,EAAE,qBAAqB,GAAG,qBAAqB,EAAE,GAC3D,OAAO,CAAC,aAAa,CAAC,qBAAqB,CAAC,CAAC,CAAC;IAEjD;;OAEG;IACH,UAAU,IAAI,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC;IAE7C;;;;OAIG;IACH,YAAY,CAAC,QAAQ,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,kBAAkB,CAAC,CAAC,CAAC;CACtG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wallet-provider.interface.js","sourceRoot":"","sources":["../../../../../../libs/wallet-sdk/src/lib/interfaces/wallet-provider.interface.ts"],"names":[],"mappings":"","sourcesContent":["import { BlockchainTransaction } from './blockchain-transaction.interface';\nimport { ConnectParams } from './connect-params.interface';\nimport { PurchaseItemType } from './purchase-item.interface';\nimport {\n ConnectResult,\n DisconnectResponse,\n PurchaseItemResult,\n SignMessageResult,\n SignTransactionResult,\n UltraResponse,\n} from './wallet-provider-response.interface';\n\n/**\n * Defines the minimal interface that a wallet provider must implement for the Ultra Wallet SDK.\n */\nexport interface UltraWalletProvider {\n /**\n * Prompt the user for permission to share his wallet info with the 3rd party application.\n * Once permission is established the first time, the 3rd party application will be whitelisted for future requests.\n * @param params.onlyIfTrusted - Do not prompt the user for permissions. Share current account info if Dapp is already trusted,\n * otherwise rejects the request.\n */\n connect(params?: ConnectParams): Promise<UltraResponse<ConnectResult>>;\n\n /**\n * Remove permission to interact with the 3rd party application\n */\n disconnect(): Promise<UltraResponse<DisconnectResponse>>;\n\n /**\n * Open a popup to sign a message\n * @param message - The message to sign. The message should be prefixed with \"0x:, UOSx:, or message:\"\n */\n signMessage(message: string): Promise<UltraResponse<SignMessageResult>>;\n\n /**\n * Open a popup to sign a transaction\n * @param transaction - The transaction to sign\n */\n signTransaction(\n transaction: BlockchainTransaction | BlockchainTransaction[],\n ): Promise<UltraResponse<SignTransactionResult>>;\n\n /**\n * Get current chain id\n */\n getChainId(): Promise<UltraResponse<string>>;\n\n /**\n * Open a popup to purchase an item\n * @param {PurchaseItemType} itemType - The type of item to purchase\n * @param {string} itemId - The id of the item to purchase\n */\n purchaseItem(itemType: PurchaseItemType, itemId: string): Promise<UltraResponse<PurchaseItemResult>>;\n}\n"]}
|
package/src/lib/interfaces/{wallet-sdk-options.interface.ts → wallet-sdk-options.interface.d.ts}
RENAMED
|
@@ -5,5 +5,6 @@
|
|
|
5
5
|
* @property {('mainnet' | 'testnet' | string)} [environment] - Target environment; defaults to 'mainnet' if unspecified.
|
|
6
6
|
*/
|
|
7
7
|
export interface UltraWalletSdkOptions {
|
|
8
|
-
|
|
8
|
+
environment?: 'mainnet' | 'testnet' | string;
|
|
9
9
|
}
|
|
10
|
+
//# sourceMappingURL=wallet-sdk-options.interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wallet-sdk-options.interface.d.ts","sourceRoot":"","sources":["../../../../../../libs/wallet-sdk/src/lib/interfaces/wallet-sdk-options.interface.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,WAAW,qBAAqB;IACpC,WAAW,CAAC,EAAE,SAAS,GAAG,SAAS,GAAG,MAAM,CAAC;CAC9C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wallet-sdk-options.interface.js","sourceRoot":"","sources":["../../../../../../libs/wallet-sdk/src/lib/interfaces/wallet-sdk-options.interface.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Options to configure the UltraWalletClient behavior.\n * Used primarily when falling back to the Web Wallet if no Ultra extension is available.\n *\n * @property {('mainnet' | 'testnet' | string)} [environment] - Target environment; defaults to 'mainnet' if unspecified.\n */\nexport interface UltraWalletSdkOptions {\n environment?: 'mainnet' | 'testnet' | string;\n}\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { BlockchainTransaction, ConnectParams, ConnectResult, PurchaseItemResult, PurchaseItemType, SignMessageResult, SignTransactionResult, UltraResponse, UltraWalletProvider, UltraWalletSdkOptions } from '../../interfaces';
|
|
2
|
+
declare global {
|
|
3
|
+
interface Window {
|
|
4
|
+
ultra: UltraWalletProvider;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
export declare class ExtensionProvider implements UltraWalletProvider {
|
|
8
|
+
private readonly options?;
|
|
9
|
+
constructor(options?: UltraWalletSdkOptions);
|
|
10
|
+
connect(params?: ConnectParams): Promise<UltraResponse<ConnectResult>>;
|
|
11
|
+
disconnect(): Promise<UltraResponse<boolean>>;
|
|
12
|
+
signMessage(message: string): Promise<UltraResponse<SignMessageResult>>;
|
|
13
|
+
signTransaction(transaction: BlockchainTransaction | BlockchainTransaction[]): Promise<UltraResponse<SignTransactionResult>>;
|
|
14
|
+
getChainId(): Promise<UltraResponse<string>>;
|
|
15
|
+
purchaseItem(itemType: PurchaseItemType, itemId: string): Promise<UltraResponse<PurchaseItemResult>>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=extension.provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extension.provider.d.ts","sourceRoot":"","sources":["../../../../../../../libs/wallet-sdk/src/lib/providers/extension-provider/extension.provider.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,aAAa,EACb,aAAa,EACb,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,qBAAqB,EACrB,aAAa,EACb,mBAAmB,EACnB,qBAAqB,EACtB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,KAAK,EAAE,mBAAmB,CAAC;KAC5B;CACF;AAED,qBAAa,iBAAkB,YAAW,mBAAmB;IAC/C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC;gBAAR,OAAO,CAAC,EAAE,qBAAqB;IAEtD,OAAO,CAAC,MAAM,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;IAU5E,UAAU,IAAI,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IAI7C,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,iBAAiB,CAAC,CAAC;IAIvE,eAAe,CACb,WAAW,EAAE,qBAAqB,GAAG,qBAAqB,EAAE,GAC3D,OAAO,CAAC,aAAa,CAAC,qBAAqB,CAAC,CAAC;IAIhD,UAAU,IAAI,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;IAI5C,YAAY,CAAC,QAAQ,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,kBAAkB,CAAC,CAAC;CAGrG"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { isValidChain } from '../../utils/chain-validator';
|
|
2
|
+
export class ExtensionProvider {
|
|
3
|
+
constructor(options) {
|
|
4
|
+
this.options = options;
|
|
5
|
+
}
|
|
6
|
+
async connect(params) {
|
|
7
|
+
const { data: chainId } = await window.ultra.getChainId();
|
|
8
|
+
if (!isValidChain(this.options?.environment, chainId)) {
|
|
9
|
+
throw new Error(`Wallet environment mismatch: expected "${this.options?.environment}" chain, but received "${chainId}". Please verify the SDK configuration and the connected network.`);
|
|
10
|
+
}
|
|
11
|
+
return window.ultra.connect(params);
|
|
12
|
+
}
|
|
13
|
+
disconnect() {
|
|
14
|
+
return window.ultra.disconnect();
|
|
15
|
+
}
|
|
16
|
+
signMessage(message) {
|
|
17
|
+
return window.ultra.signMessage(message);
|
|
18
|
+
}
|
|
19
|
+
signTransaction(transaction) {
|
|
20
|
+
return window.ultra.signTransaction(transaction);
|
|
21
|
+
}
|
|
22
|
+
getChainId() {
|
|
23
|
+
return window.ultra.getChainId();
|
|
24
|
+
}
|
|
25
|
+
purchaseItem(itemType, itemId) {
|
|
26
|
+
return window.ultra.purchaseItem(itemType, itemId);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=extension.provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extension.provider.js","sourceRoot":"","sources":["../../../../../../../libs/wallet-sdk/src/lib/providers/extension-provider/extension.provider.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAQ3D,MAAM,OAAO,iBAAiB;IAC5B,YAA6B,OAA+B;QAA/B,YAAO,GAAP,OAAO,CAAwB;IAAG,CAAC;IAEhE,KAAK,CAAC,OAAO,CAAC,MAAsB;QAClC,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC;QAC1D,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,CAAC;YACtD,MAAM,IAAI,KAAK,CACb,0CAA0C,IAAI,CAAC,OAAO,EAAE,WAAW,0BAA0B,OAAO,mEAAmE,CACxK,CAAC;QACJ,CAAC;QACD,OAAO,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACtC,CAAC;IAED,UAAU;QACR,OAAO,MAAM,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC;IACnC,CAAC;IAED,WAAW,CAAC,OAAe;QACzB,OAAO,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IAC3C,CAAC;IAED,eAAe,CACb,WAA4D;QAE5D,OAAO,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC;IACnD,CAAC;IAED,UAAU;QACR,OAAO,MAAM,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC;IACnC,CAAC;IAED,YAAY,CAAC,QAA0B,EAAE,MAAc;QACrD,OAAO,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IACrD,CAAC;CACF","sourcesContent":["import {\n BlockchainTransaction,\n ConnectParams,\n ConnectResult,\n PurchaseItemResult,\n PurchaseItemType,\n SignMessageResult,\n SignTransactionResult,\n UltraResponse,\n UltraWalletProvider,\n UltraWalletSdkOptions,\n} from '../../interfaces';\nimport { isValidChain } from '../../utils/chain-validator';\n\ndeclare global {\n interface Window {\n ultra: UltraWalletProvider;\n }\n}\n\nexport class ExtensionProvider implements UltraWalletProvider {\n constructor(private readonly options?: UltraWalletSdkOptions) {}\n\n async connect(params?: ConnectParams): Promise<UltraResponse<ConnectResult>> {\n const { data: chainId } = await window.ultra.getChainId();\n if (!isValidChain(this.options?.environment, chainId)) {\n throw new Error(\n `Wallet environment mismatch: expected \"${this.options?.environment}\" chain, but received \"${chainId}\". Please verify the SDK configuration and the connected network.`,\n );\n }\n return window.ultra.connect(params);\n }\n\n disconnect(): Promise<UltraResponse<boolean>> {\n return window.ultra.disconnect();\n }\n\n signMessage(message: string): Promise<UltraResponse<SignMessageResult>> {\n return window.ultra.signMessage(message);\n }\n\n signTransaction(\n transaction: BlockchainTransaction | BlockchainTransaction[],\n ): Promise<UltraResponse<SignTransactionResult>> {\n return window.ultra.signTransaction(transaction);\n }\n\n getChainId(): Promise<UltraResponse<string>> {\n return window.ultra.getChainId();\n }\n\n purchaseItem(itemType: PurchaseItemType, itemId: string): Promise<UltraResponse<PurchaseItemResult>> {\n return window.ultra.purchaseItem(itemType, itemId);\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../libs/wallet-sdk/src/lib/providers/index.ts"],"names":[],"mappings":"AAAA,cAAc,yCAAyC,CAAC;AACxD,cAAc,6BAA6B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../libs/wallet-sdk/src/lib/providers/index.ts"],"names":[],"mappings":"AAAA,cAAc,yCAAyC,CAAC;AACxD,cAAc,6BAA6B,CAAC","sourcesContent":["export * from './extension-provider/extension.provider';\nexport * from './web-provider/web.provider';\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BlockchainTransaction, ConnectParams, ConnectResult, PurchaseItemResult, PurchaseItemType, SignMessageResult, SignTransactionResult, UltraResponse, UltraWalletProvider, UltraWalletSdkOptions } from '../../interfaces';
|
|
2
|
+
export declare class WebProvider implements UltraWalletProvider {
|
|
3
|
+
private readonly options?;
|
|
4
|
+
private readonly windowManager;
|
|
5
|
+
private readonly clientMessenger;
|
|
6
|
+
constructor(options?: UltraWalletSdkOptions);
|
|
7
|
+
connect(_?: ConnectParams): Promise<UltraResponse<ConnectResult>>;
|
|
8
|
+
disconnect(): Promise<UltraResponse<boolean>>;
|
|
9
|
+
signMessage(message: string): Promise<UltraResponse<SignMessageResult>>;
|
|
10
|
+
signTransaction(transaction: BlockchainTransaction | BlockchainTransaction[]): Promise<UltraResponse<SignTransactionResult>>;
|
|
11
|
+
getChainId(): Promise<UltraResponse<string>>;
|
|
12
|
+
purchaseItem(itemType: PurchaseItemType, itemId: string): Promise<UltraResponse<PurchaseItemResult>>;
|
|
13
|
+
private resolveWalletUrl;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=web.provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web.provider.d.ts","sourceRoot":"","sources":["../../../../../../../libs/wallet-sdk/src/lib/providers/web-provider/web.provider.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,qBAAqB,EACrB,aAAa,EACb,aAAa,EACb,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,qBAAqB,EACrB,aAAa,EACb,mBAAmB,EACnB,qBAAqB,EACtB,MAAM,kBAAkB,CAAC;AAE1B,qBAAa,WAAY,YAAW,mBAAmB;IAIzC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC;IAHrC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAgB;IAC9C,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAkB;gBAErB,OAAO,CAAC,EAAE,qBAAqB;IAK5D,OAAO,CAAC,CAAC,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;IAIjE,UAAU,IAAI,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IAI7C,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,iBAAiB,CAAC,CAAC;IAIvE,eAAe,CACb,WAAW,EAAE,qBAAqB,GAAG,qBAAqB,EAAE,GAC3D,OAAO,CAAC,aAAa,CAAC,qBAAqB,CAAC,CAAC;IAIhD,UAAU,IAAI,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;IAI5C,YAAY,CAAC,QAAQ,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,kBAAkB,CAAC,CAAC;IAOpG,OAAO,CAAC,gBAAgB;CAIzB"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ClientMessenger } from '../../common/client-messenger';
|
|
2
|
+
import { WindowManager } from '../../common/window-manager';
|
|
3
|
+
import UltraWalletSdkConfig from '../../config/ultra-wallet-sdk.config';
|
|
4
|
+
export class WebProvider {
|
|
5
|
+
constructor(options) {
|
|
6
|
+
this.options = options;
|
|
7
|
+
this.windowManager = new WindowManager(this.resolveWalletUrl());
|
|
8
|
+
this.clientMessenger = new ClientMessenger(this.windowManager);
|
|
9
|
+
}
|
|
10
|
+
connect(_) {
|
|
11
|
+
return this.clientMessenger.sendRequest('connect', {});
|
|
12
|
+
}
|
|
13
|
+
disconnect() {
|
|
14
|
+
return this.clientMessenger.sendRequest('disconnect', {});
|
|
15
|
+
}
|
|
16
|
+
signMessage(message) {
|
|
17
|
+
return this.clientMessenger.sendRequest('signMessage', { message });
|
|
18
|
+
}
|
|
19
|
+
signTransaction(transaction) {
|
|
20
|
+
return this.clientMessenger.sendRequest('signTransaction', { transaction });
|
|
21
|
+
}
|
|
22
|
+
getChainId() {
|
|
23
|
+
return this.clientMessenger.sendRequest('getChainId', {});
|
|
24
|
+
}
|
|
25
|
+
purchaseItem(itemType, itemId) {
|
|
26
|
+
return this.clientMessenger.sendRequest('purchaseItem', {
|
|
27
|
+
itemType,
|
|
28
|
+
itemId,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
resolveWalletUrl() {
|
|
32
|
+
const env = UltraWalletSdkConfig.walletUrls[this.options?.environment || 'mainnet'];
|
|
33
|
+
return env || this.options.environment;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=web.provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web.provider.js","sourceRoot":"","sources":["../../../../../../../libs/wallet-sdk/src/lib/providers/web-provider/web.provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,oBAAoB,MAAM,sCAAsC,CAAC;AAcxE,MAAM,OAAO,WAAW;IAItB,YAA6B,OAA+B;QAA/B,YAAO,GAAP,OAAO,CAAwB;QAC1D,IAAI,CAAC,aAAa,GAAG,IAAI,aAAa,CAAC,IAAI,CAAC,gBAAgB,EAAE,CAAC,CAAC;QAChE,IAAI,CAAC,eAAe,GAAG,IAAI,eAAe,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IACjE,CAAC;IAED,OAAO,CAAC,CAAiB;QACvB,OAAO,IAAI,CAAC,eAAe,CAAC,WAAW,CAAgB,SAAS,EAAE,EAAE,CAAC,CAAC;IACxE,CAAC;IAED,UAAU;QACR,OAAO,IAAI,CAAC,eAAe,CAAC,WAAW,CAAU,YAAY,EAAE,EAAE,CAAC,CAAC;IACrE,CAAC;IAED,WAAW,CAAC,OAAe;QACzB,OAAO,IAAI,CAAC,eAAe,CAAC,WAAW,CAAoB,aAAa,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;IACzF,CAAC;IAED,eAAe,CACb,WAA4D;QAE5D,OAAO,IAAI,CAAC,eAAe,CAAC,WAAW,CAAwB,iBAAiB,EAAE,EAAE,WAAW,EAAE,CAAC,CAAC;IACrG,CAAC;IAED,UAAU;QACR,OAAO,IAAI,CAAC,eAAe,CAAC,WAAW,CAAS,YAAY,EAAE,EAAE,CAAC,CAAC;IACpE,CAAC;IAED,YAAY,CAAC,QAA0B,EAAE,MAAc;QACrD,OAAO,IAAI,CAAC,eAAe,CAAC,WAAW,CAAqB,cAAc,EAAE;YAC1E,QAAQ;YACR,MAAM;SACP,CAAC,CAAC;IACL,CAAC;IAEO,gBAAgB;QACtB,MAAM,GAAG,GAAG,oBAAoB,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,WAAW,IAAI,SAAS,CAAC,CAAC;QACpF,OAAO,GAAG,IAAI,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC;IACzC,CAAC;CACF","sourcesContent":["import { ClientMessenger } from '../../common/client-messenger';\nimport { WindowManager } from '../../common/window-manager';\nimport UltraWalletSdkConfig from '../../config/ultra-wallet-sdk.config';\nimport {\n BlockchainTransaction,\n ConnectParams,\n ConnectResult,\n PurchaseItemResult,\n PurchaseItemType,\n SignMessageResult,\n SignTransactionResult,\n UltraResponse,\n UltraWalletProvider,\n UltraWalletSdkOptions,\n} from '../../interfaces';\n\nexport class WebProvider implements UltraWalletProvider {\n private readonly windowManager: WindowManager;\n private readonly clientMessenger: ClientMessenger;\n\n constructor(private readonly options?: UltraWalletSdkOptions) {\n this.windowManager = new WindowManager(this.resolveWalletUrl());\n this.clientMessenger = new ClientMessenger(this.windowManager);\n }\n\n connect(_?: ConnectParams): Promise<UltraResponse<ConnectResult>> {\n return this.clientMessenger.sendRequest<ConnectResult>('connect', {});\n }\n\n disconnect(): Promise<UltraResponse<boolean>> {\n return this.clientMessenger.sendRequest<boolean>('disconnect', {});\n }\n\n signMessage(message: string): Promise<UltraResponse<SignMessageResult>> {\n return this.clientMessenger.sendRequest<SignMessageResult>('signMessage', { message });\n }\n\n signTransaction(\n transaction: BlockchainTransaction | BlockchainTransaction[],\n ): Promise<UltraResponse<SignTransactionResult>> {\n return this.clientMessenger.sendRequest<SignTransactionResult>('signTransaction', { transaction });\n }\n\n getChainId(): Promise<UltraResponse<string>> {\n return this.clientMessenger.sendRequest<string>('getChainId', {});\n }\n\n purchaseItem(itemType: PurchaseItemType, itemId: string): Promise<UltraResponse<PurchaseItemResult>> {\n return this.clientMessenger.sendRequest<PurchaseItemResult>('purchaseItem', {\n itemType,\n itemId,\n });\n }\n\n private resolveWalletUrl(): string {\n const env = UltraWalletSdkConfig.walletUrls[this.options?.environment || 'mainnet'];\n return env || this.options.environment;\n }\n}\n"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { BlockchainTransaction, ConnectParams, ConnectResult, PurchaseItemResult, PurchaseItemType, SignMessageResult, SignTransactionResult, UltraResponse, UltraWalletSdkOptions } from './interfaces';
|
|
2
|
+
/**
|
|
3
|
+
* UltraWalletClient acts as a Facade for interacting with the Ultra Wallet.
|
|
4
|
+
* It provides a unified API regardless of the underlying provider implementation (Extension or Web).
|
|
5
|
+
*/
|
|
6
|
+
export declare class UltraWalletSDK {
|
|
7
|
+
private readonly options?;
|
|
8
|
+
private provider;
|
|
9
|
+
/**
|
|
10
|
+
* Constructs an UltraWalletClient instance.
|
|
11
|
+
* If the Ultra Wallet Extension is available (window.ultra), it will be used automatically.
|
|
12
|
+
* If the Extension is not available, the Web Wallet provider will be initialized using the given network options.
|
|
13
|
+
*
|
|
14
|
+
* @param {UltraWalletSdkOptions} [options] - Configuration options for the Web Wallet fallback (environment or custom URL).
|
|
15
|
+
*/
|
|
16
|
+
constructor(options?: UltraWalletSdkOptions);
|
|
17
|
+
connect(params?: ConnectParams): Promise<UltraResponse<ConnectResult>>;
|
|
18
|
+
disconnect(): Promise<UltraResponse<boolean>>;
|
|
19
|
+
signMessage(message: string): Promise<UltraResponse<SignMessageResult>>;
|
|
20
|
+
signTransaction(transaction: BlockchainTransaction | BlockchainTransaction[]): Promise<UltraResponse<SignTransactionResult>>;
|
|
21
|
+
getChainId(): Promise<UltraResponse<string>>;
|
|
22
|
+
purchaseItem(itemType: PurchaseItemType, itemId: string): Promise<UltraResponse<PurchaseItemResult>>;
|
|
23
|
+
private resolveWalletProvider;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=ultra-wallet-sdk.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ultra-wallet-sdk.d.ts","sourceRoot":"","sources":["../../../../../libs/wallet-sdk/src/lib/ultra-wallet-sdk.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,aAAa,EACb,aAAa,EACb,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,qBAAqB,EACrB,aAAa,EAEb,qBAAqB,EACtB,MAAM,cAAc,CAAC;AAItB;;;GAGG;AACH,qBAAa,cAAc;IAUb,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC;IATrC,OAAO,CAAC,QAAQ,CAAsB;IAEtC;;;;;;OAMG;gBAC0B,OAAO,CAAC,EAAE,qBAAqB;IAI5D,OAAO,CAAC,MAAM,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;IAItE,UAAU,IAAI,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IAI7C,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,iBAAiB,CAAC,CAAC;IAIvE,eAAe,CACb,WAAW,EAAE,qBAAqB,GAAG,qBAAqB,EAAE,GAC3D,OAAO,CAAC,aAAa,CAAC,qBAAqB,CAAC,CAAC;IAIhD,UAAU,IAAI,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;IAI5C,YAAY,CAAC,QAAQ,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,kBAAkB,CAAC,CAAC;IAIpG,OAAO,CAAC,qBAAqB;CAO9B"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { ExtensionProvider, WebProvider } from './providers';
|
|
2
|
+
import { isExtensionAvailable } from './utils/detection';
|
|
3
|
+
/**
|
|
4
|
+
* UltraWalletClient acts as a Facade for interacting with the Ultra Wallet.
|
|
5
|
+
* It provides a unified API regardless of the underlying provider implementation (Extension or Web).
|
|
6
|
+
*/
|
|
7
|
+
export class UltraWalletSDK {
|
|
8
|
+
/**
|
|
9
|
+
* Constructs an UltraWalletClient instance.
|
|
10
|
+
* If the Ultra Wallet Extension is available (window.ultra), it will be used automatically.
|
|
11
|
+
* If the Extension is not available, the Web Wallet provider will be initialized using the given network options.
|
|
12
|
+
*
|
|
13
|
+
* @param {UltraWalletSdkOptions} [options] - Configuration options for the Web Wallet fallback (environment or custom URL).
|
|
14
|
+
*/
|
|
15
|
+
constructor(options) {
|
|
16
|
+
this.options = options;
|
|
17
|
+
this.provider = this.resolveWalletProvider();
|
|
18
|
+
}
|
|
19
|
+
connect(params) {
|
|
20
|
+
return this.provider.connect(params);
|
|
21
|
+
}
|
|
22
|
+
disconnect() {
|
|
23
|
+
return this.provider.disconnect();
|
|
24
|
+
}
|
|
25
|
+
signMessage(message) {
|
|
26
|
+
return this.provider.signMessage(message);
|
|
27
|
+
}
|
|
28
|
+
signTransaction(transaction) {
|
|
29
|
+
return this.provider.signTransaction(transaction);
|
|
30
|
+
}
|
|
31
|
+
getChainId() {
|
|
32
|
+
return this.provider.getChainId();
|
|
33
|
+
}
|
|
34
|
+
purchaseItem(itemType, itemId) {
|
|
35
|
+
return this.provider.purchaseItem(itemType, itemId);
|
|
36
|
+
}
|
|
37
|
+
resolveWalletProvider() {
|
|
38
|
+
if (isExtensionAvailable()) {
|
|
39
|
+
return new ExtensionProvider();
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
return new WebProvider(this.options);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=ultra-wallet-sdk.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ultra-wallet-sdk.js","sourceRoot":"","sources":["../../../../../libs/wallet-sdk/src/lib/ultra-wallet-sdk.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAEzD;;;GAGG;AACH,MAAM,OAAO,cAAc;IAGzB;;;;;;OAMG;IACH,YAA6B,OAA+B;QAA/B,YAAO,GAAP,OAAO,CAAwB;QAC1D,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,qBAAqB,EAAE,CAAC;IAC/C,CAAC;IAED,OAAO,CAAC,MAAsB;QAC5B,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACvC,CAAC;IAED,UAAU;QACR,OAAO,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;IACpC,CAAC;IAED,WAAW,CAAC,OAAe;QACzB,OAAO,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IAC5C,CAAC;IAED,eAAe,CACb,WAA4D;QAE5D,OAAO,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC;IACpD,CAAC;IAED,UAAU;QACR,OAAO,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;IACpC,CAAC;IAED,YAAY,CAAC,QAA0B,EAAE,MAAc;QACrD,OAAO,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IACtD,CAAC;IAEO,qBAAqB;QAC3B,IAAI,oBAAoB,EAAE,EAAE,CAAC;YAC3B,OAAO,IAAI,iBAAiB,EAAE,CAAC;QACjC,CAAC;aAAM,CAAC;YACN,OAAO,IAAI,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACvC,CAAC;IACH,CAAC;CACF","sourcesContent":["import {\n BlockchainTransaction,\n ConnectParams,\n ConnectResult,\n PurchaseItemResult,\n PurchaseItemType,\n SignMessageResult,\n SignTransactionResult,\n UltraResponse,\n UltraWalletProvider,\n UltraWalletSdkOptions,\n} from './interfaces';\nimport { ExtensionProvider, WebProvider } from './providers';\nimport { isExtensionAvailable } from './utils/detection';\n\n/**\n * UltraWalletClient acts as a Facade for interacting with the Ultra Wallet.\n * It provides a unified API regardless of the underlying provider implementation (Extension or Web).\n */\nexport class UltraWalletSDK {\n private provider: UltraWalletProvider;\n\n /**\n * Constructs an UltraWalletClient instance.\n * If the Ultra Wallet Extension is available (window.ultra), it will be used automatically.\n * If the Extension is not available, the Web Wallet provider will be initialized using the given network options.\n *\n * @param {UltraWalletSdkOptions} [options] - Configuration options for the Web Wallet fallback (environment or custom URL).\n */\n constructor(private readonly options?: UltraWalletSdkOptions) {\n this.provider = this.resolveWalletProvider();\n }\n\n connect(params?: ConnectParams): Promise<UltraResponse<ConnectResult>> {\n return this.provider.connect(params);\n }\n\n disconnect(): Promise<UltraResponse<boolean>> {\n return this.provider.disconnect();\n }\n\n signMessage(message: string): Promise<UltraResponse<SignMessageResult>> {\n return this.provider.signMessage(message);\n }\n\n signTransaction(\n transaction: BlockchainTransaction | BlockchainTransaction[],\n ): Promise<UltraResponse<SignTransactionResult>> {\n return this.provider.signTransaction(transaction);\n }\n\n getChainId(): Promise<UltraResponse<string>> {\n return this.provider.getChainId();\n }\n\n purchaseItem(itemType: PurchaseItemType, itemId: string): Promise<UltraResponse<PurchaseItemResult>> {\n return this.provider.purchaseItem(itemType, itemId);\n }\n\n private resolveWalletProvider(): UltraWalletProvider {\n if (isExtensionAvailable()) {\n return new ExtensionProvider();\n } else {\n return new WebProvider(this.options);\n }\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chain-validator.d.ts","sourceRoot":"","sources":["../../../../../../libs/wallet-sdk/src/lib/utils/chain-validator.ts"],"names":[],"mappings":"AAEA,wBAAgB,YAAY,CAAC,aAAa,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAGlF"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import UltraWalletSdkConfig from '../config/ultra-wallet-sdk.config';
|
|
2
|
+
export function isValidChain(targetNetwork, walletChainId) {
|
|
3
|
+
const { chainId } = UltraWalletSdkConfig.networkInfo[targetNetwork] || {};
|
|
4
|
+
return !chainId || chainId === walletChainId;
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=chain-validator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chain-validator.js","sourceRoot":"","sources":["../../../../../../libs/wallet-sdk/src/lib/utils/chain-validator.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,MAAM,mCAAmC,CAAC;AAErE,MAAM,UAAU,YAAY,CAAC,aAAqB,EAAE,aAAqB;IACvE,MAAM,EAAE,OAAO,EAAE,GAAG,oBAAoB,CAAC,WAAW,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC;IAC1E,OAAO,CAAC,OAAO,IAAI,OAAO,KAAK,aAAa,CAAC;AAC/C,CAAC","sourcesContent":["import UltraWalletSdkConfig from '../config/ultra-wallet-sdk.config';\n\nexport function isValidChain(targetNetwork: string, walletChainId: string): boolean {\n const { chainId } = UltraWalletSdkConfig.networkInfo[targetNetwork] || {};\n return !chainId || chainId === walletChainId;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detection.d.ts","sourceRoot":"","sources":["../../../../../../libs/wallet-sdk/src/lib/utils/detection.ts"],"names":[],"mappings":"AAAA,wBAAgB,oBAAoB,IAAI,OAAO,CAE9C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detection.js","sourceRoot":"","sources":["../../../../../../libs/wallet-sdk/src/lib/utils/detection.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,oBAAoB;IAClC,OAAO,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,IAAI,MAAM,CAAC;AAC5D,CAAC","sourcesContent":["export function isExtensionAvailable(): boolean {\n return typeof window !== 'undefined' && 'ultra' in window;\n}\n"]}
|
package/LICENSE
DELETED
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
GNU LESSER GENERAL PUBLIC LICENSE
|
|
2
|
-
Version 3, 29 June 2007
|
|
3
|
-
|
|
4
|
-
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
|
5
|
-
Everyone is permitted to copy and distribute verbatim copies
|
|
6
|
-
of this license document, but changing it is not allowed.
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
This version of the GNU Lesser General Public License incorporates
|
|
10
|
-
the terms and conditions of version 3 of the GNU General Public
|
|
11
|
-
License, supplemented by the additional permissions listed below.
|
|
12
|
-
|
|
13
|
-
0. Additional Definitions.
|
|
14
|
-
|
|
15
|
-
As used herein, "this License" refers to version 3 of the GNU Lesser
|
|
16
|
-
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
|
17
|
-
General Public License.
|
|
18
|
-
|
|
19
|
-
"The Library" refers to a covered work governed by this License,
|
|
20
|
-
other than an Application or a Combined Work as defined below.
|
|
21
|
-
|
|
22
|
-
An "Application" is any work that makes use of an interface provided
|
|
23
|
-
by the Library, but which is not otherwise based on the Library.
|
|
24
|
-
Defining a subclass of a class defined by the Library is deemed a mode
|
|
25
|
-
of using an interface provided by the Library.
|
|
26
|
-
|
|
27
|
-
A "Combined Work" is a work produced by combining or linking an
|
|
28
|
-
Application with the Library. The particular version of the Library
|
|
29
|
-
with which the Combined Work was made is also called the "Linked
|
|
30
|
-
Version".
|
|
31
|
-
|
|
32
|
-
The "Minimal Corresponding Source" for a Combined Work means the
|
|
33
|
-
Corresponding Source for the Combined Work, excluding any source code
|
|
34
|
-
for portions of the Combined Work that, considered in isolation, are
|
|
35
|
-
based on the Application, and not on the Linked Version.
|
|
36
|
-
|
|
37
|
-
The "Corresponding Application Code" for a Combined Work means the
|
|
38
|
-
object code and/or source code for the Application, including any data
|
|
39
|
-
and utility programs needed for reproducing the Combined Work from the
|
|
40
|
-
Application, but excluding the System Libraries of the Combined Work.
|
|
41
|
-
|
|
42
|
-
1. Exception to Section 3 of the GNU GPL.
|
|
43
|
-
|
|
44
|
-
You may convey a covered work under sections 3 and 4 of this License
|
|
45
|
-
without being bound by section 3 of the GNU GPL.
|
|
46
|
-
|
|
47
|
-
2. Conveying Modified Versions.
|
|
48
|
-
|
|
49
|
-
If you modify a copy of the Library, and, in your modifications, a
|
|
50
|
-
facility refers to a function or data to be supplied by an Application
|
|
51
|
-
that uses the facility (other than as an argument passed when the
|
|
52
|
-
facility is invoked), then you may convey a copy of the modified
|
|
53
|
-
version:
|
|
54
|
-
|
|
55
|
-
a) under this License, provided that you make a good faith effort to
|
|
56
|
-
ensure that, in the event an Application does not supply the
|
|
57
|
-
function or data, the facility still operates, and performs
|
|
58
|
-
whatever part of its purpose remains meaningful, or
|
|
59
|
-
|
|
60
|
-
b) under the GNU GPL, with none of the additional permissions of
|
|
61
|
-
this License applicable to that copy.
|
|
62
|
-
|
|
63
|
-
3. Object Code Incorporating Material from Library Header Files.
|
|
64
|
-
|
|
65
|
-
The object code form of an Application may incorporate material from
|
|
66
|
-
a header file that is part of the Library. You may convey such object
|
|
67
|
-
code under terms of your choice, provided that, if the incorporated
|
|
68
|
-
material is not limited to numerical parameters, data structure
|
|
69
|
-
layouts and accessors, or small macros, inline functions and templates
|
|
70
|
-
(ten or fewer lines in length), you do both of the following:
|
|
71
|
-
|
|
72
|
-
a) Give prominent notice with each copy of the object code that the
|
|
73
|
-
Library is used in it and that the Library and its use are
|
|
74
|
-
covered by this License.
|
|
75
|
-
|
|
76
|
-
b) Accompany the object code with a copy of the GNU GPL and this license
|
|
77
|
-
document.
|
|
78
|
-
|
|
79
|
-
4. Combined Works.
|
|
80
|
-
|
|
81
|
-
You may convey a Combined Work under terms of your choice that,
|
|
82
|
-
taken together, effectively do not restrict modification of the
|
|
83
|
-
portions of the Library contained in the Combined Work and reverse
|
|
84
|
-
engineering for debugging such modifications, if you also do each of
|
|
85
|
-
the following:
|
|
86
|
-
|
|
87
|
-
a) Give prominent notice with each copy of the Combined Work that
|
|
88
|
-
the Library is used in it and that the Library and its use are
|
|
89
|
-
covered by this License.
|
|
90
|
-
|
|
91
|
-
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
|
92
|
-
document.
|
|
93
|
-
|
|
94
|
-
c) For a Combined Work that displays copyright notices during
|
|
95
|
-
execution, include the copyright notice for the Library among
|
|
96
|
-
these notices, as well as a reference directing the user to the
|
|
97
|
-
copies of the GNU GPL and this license document.
|
|
98
|
-
|
|
99
|
-
d) Do one of the following:
|
|
100
|
-
|
|
101
|
-
0) Convey the Minimal Corresponding Source under the terms of this
|
|
102
|
-
License, and the Corresponding Application Code in a form
|
|
103
|
-
suitable for, and under terms that permit, the user to
|
|
104
|
-
recombine or relink the Application with a modified version of
|
|
105
|
-
the Linked Version to produce a modified Combined Work, in the
|
|
106
|
-
manner specified by section 6 of the GNU GPL for conveying
|
|
107
|
-
Corresponding Source.
|
|
108
|
-
|
|
109
|
-
1) Use a suitable shared library mechanism for linking with the
|
|
110
|
-
Library. A suitable mechanism is one that (a) uses at run time
|
|
111
|
-
a copy of the Library already present on the user's computer
|
|
112
|
-
system, and (b) will operate properly with a modified version
|
|
113
|
-
of the Library that is interface-compatible with the Linked
|
|
114
|
-
Version.
|
|
115
|
-
|
|
116
|
-
e) Provide Installation Information, but only if you would otherwise
|
|
117
|
-
be required to provide such information under section 6 of the
|
|
118
|
-
GNU GPL, and only to the extent that such information is
|
|
119
|
-
necessary to install and execute a modified version of the
|
|
120
|
-
Combined Work produced by recombining or relinking the
|
|
121
|
-
Application with a modified version of the Linked Version. (If
|
|
122
|
-
you use option 4d0, the Installation Information must accompany
|
|
123
|
-
the Minimal Corresponding Source and Corresponding Application
|
|
124
|
-
Code. If you use option 4d1, you must provide the Installation
|
|
125
|
-
Information in the manner specified by section 6 of the GNU GPL
|
|
126
|
-
for conveying Corresponding Source.)
|
|
127
|
-
|
|
128
|
-
5. Combined Libraries.
|
|
129
|
-
|
|
130
|
-
You may place library facilities that are a work based on the
|
|
131
|
-
Library side by side in a single library together with other library
|
|
132
|
-
facilities that are not Applications and are not covered by this
|
|
133
|
-
License, and convey such a combined library under terms of your
|
|
134
|
-
choice, if you do both of the following:
|
|
135
|
-
|
|
136
|
-
a) Accompany the combined library with a copy of the same work based
|
|
137
|
-
on the Library, uncombined with any other library facilities,
|
|
138
|
-
conveyed under the terms of this License.
|
|
139
|
-
|
|
140
|
-
b) Give prominent notice with the combined library that part of it
|
|
141
|
-
is a work based on the Library, and explaining where to find the
|
|
142
|
-
accompanying uncombined form of the same work.
|
|
143
|
-
|
|
144
|
-
6. Revised Versions of the GNU Lesser General Public License.
|
|
145
|
-
|
|
146
|
-
The Free Software Foundation may publish revised and/or new versions
|
|
147
|
-
of the GNU Lesser General Public License from time to time. Such new
|
|
148
|
-
versions will be similar in spirit to the present version, but may
|
|
149
|
-
differ in detail to address new problems or concerns.
|
|
150
|
-
|
|
151
|
-
Each version is given a distinguishing version number. If the
|
|
152
|
-
Library as you received it specifies that a certain numbered version
|
|
153
|
-
of the GNU Lesser General Public License "or any later version"
|
|
154
|
-
applies to it, you have the option of following the terms and
|
|
155
|
-
conditions either of that published version or of any later version
|
|
156
|
-
published by the Free Software Foundation. If the Library as you
|
|
157
|
-
received it does not specify a version number of the GNU Lesser
|
|
158
|
-
General Public License, you may choose any version of the GNU Lesser
|
|
159
|
-
General Public License ever published by the Free Software Foundation.
|
|
160
|
-
|
|
161
|
-
If the Library as you received it specifies that a proxy can decide
|
|
162
|
-
whether future versions of the GNU Lesser General Public License shall
|
|
163
|
-
apply, that proxy's public statement of acceptance of any version is
|
|
164
|
-
permanent authorization for you to choose that version for the
|
|
165
|
-
Library.
|
package/README.md
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
# Ultra Wallet SDK
|
|
2
|
-
|
|
3
|
-
Ultra Wallet SDK provides an easy-to-use client for interacting with the Ultra blockchain wallet, either through the
|
|
4
|
-
browser extension or via a web fallback.
|
|
5
|
-
|
|
6
|
-
## ✨ Features
|
|
7
|
-
|
|
8
|
-
- Automatically detects and uses the Ultra Wallet Extension if available.
|
|
9
|
-
- Falls back to a Web Wallet if the extension is not installed.
|
|
10
|
-
- Connect, sign messages, sign transactions, and initiate purchases with a simple API.
|
|
11
|
-
- Environment support: `mainnet`, `testnet`, or custom wallet URLs.
|
|
12
|
-
|
|
13
|
-
## 📦 Installation
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
npm install @ultraos/wallet-sdk
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
or
|
|
20
|
-
|
|
21
|
-
```bash
|
|
22
|
-
yarn add @ultraos/wallet-sdk
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
## 🚀 Usage
|
|
26
|
-
|
|
27
|
-
```ts
|
|
28
|
-
import { UltraWalletSDK } from '@ultraos/wallet-sdk';
|
|
29
|
-
|
|
30
|
-
// Basic initialization (auto-detect extension or fallback to mainnet Web Wallet)
|
|
31
|
-
const ultra = new UltraWalletSDK();
|
|
32
|
-
|
|
33
|
-
// Optionally initialize with environment configuration
|
|
34
|
-
const ultraTestnet = new UltraWalletSDK({ environment: 'testnet' });
|
|
35
|
-
|
|
36
|
-
// Connect
|
|
37
|
-
await ultra.connect();
|
|
38
|
-
|
|
39
|
-
// Sign a message
|
|
40
|
-
const signature = await ultra.signMessage('message: Hello, Ultra!');
|
|
41
|
-
|
|
42
|
-
// Sign a transaction
|
|
43
|
-
await ultra.signTransaction({
|
|
44
|
-
contract: 'eosio.token',
|
|
45
|
-
action: 'transfer',
|
|
46
|
-
data: { from: 'user', to: 'receiver', quantity: '1.00000000 UOS', memo: '' },
|
|
47
|
-
authorizations: ['user@active'],
|
|
48
|
-
});
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
## ⚙️ Configuration
|
|
52
|
-
|
|
53
|
-
You can pass options during initialization:
|
|
54
|
-
|
|
55
|
-
```ts
|
|
56
|
-
new UltraWalletSDK({
|
|
57
|
-
environment: 'testnet', // or 'mainnet', or provide custom URL
|
|
58
|
-
});
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
## 📚 API
|
|
62
|
-
|
|
63
|
-
### Methods
|
|
64
|
-
|
|
65
|
-
- `connect(): Promise<ConnectResult>`
|
|
66
|
-
- `disconnect(): Promise<void>`
|
|
67
|
-
- `signMessage(message: string): Promise<string>`
|
|
68
|
-
- `signTransaction(transaction: BlockchainTransaction | BlockchainTransaction[]): Promise<SignTransactionResult>`
|
|
69
|
-
- `getChainId(): Promise<string>`
|
|
70
|
-
- `purchaseItem(itemType: PurchaseItemType, itemId: string): Promise<PurchaseItemResult>`
|
|
71
|
-
|
|
72
|
-
---
|
|
73
|
-
|
|
74
|
-
Tests are run with [Jest](https://jestjs.io).
|