@tari-project/tarijs 0.13.0 → 0.14.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/.prototools +3 -3
- package/docusaurus/tari-docs/package.json +1 -1
- package/package.json +3 -4
- package/packages/builders/package.json +1 -1
- package/packages/builders/src/transaction/TransactionBuilder.ts +6 -4
- package/packages/indexer_provider/package.json +1 -1
- package/packages/indexer_provider/src/transports/IndexerProviderClient.ts +0 -17
- package/packages/metamask_signer/package.json +1 -1
- package/packages/metamask_signer/src/index.ts +5 -7
- package/packages/permissions/package.json +1 -1
- package/packages/react-mui-connect-button/package.json +3 -2
- package/packages/react-mui-connect-button/src/TariConnectButton.tsx +3 -0
- package/packages/react-mui-connect-button/src/TariWalletSelectionDialog.tsx +22 -1
- package/packages/react-mui-connect-button/tsconfig.json +4 -3
- package/packages/tari_provider/package.json +1 -1
- package/packages/tari_signer/package.json +1 -1
- package/packages/tari_signer/src/TariSigner.ts +3 -3
- package/packages/tari_universe/package.json +1 -1
- package/packages/tari_universe/src/signer.ts +8 -6
- package/packages/tari_universe/src/types.ts +2 -1
- package/packages/tari_universe/src/useIframeMessage.ts +82 -0
- package/packages/tari_universe/src/utils.ts +6 -2
- package/packages/tarijs/package.json +1 -1
- package/packages/tarijs_types/package.json +1 -1
- package/packages/tarijs_types/src/ConfidentialOutput.ts +2 -2
- package/packages/tarijs_types/src/helpers/simpleResult.ts +2 -2
- package/packages/tarijs_types/src/helpers/txResult.ts +0 -8
- package/packages/tarijs_types/src/index.ts +4 -2
- package/packages/tarijs_types/src/signer.ts +20 -3
- package/packages/wallet_daemon/package.json +1 -1
- package/packages/wallet_daemon/src/provider.ts +4 -4
- package/packages/wallet_daemon/src/signer.ts +14 -14
- package/packages/walletconnect/package.json +1 -1
- package/packages/walletconnect/src/index.ts +8 -10
- package/pnpm-workspace.yaml +1 -1
package/.prototools
CHANGED
package/package.json
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tari-project/tarijs",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [],
|
|
7
7
|
"author": "The Tari Community",
|
|
8
8
|
"license": "ISC",
|
|
9
9
|
"engines": {
|
|
10
|
-
"node": "22.
|
|
10
|
+
"node": "22.19.0"
|
|
11
11
|
},
|
|
12
12
|
"devDependencies": {
|
|
13
13
|
"@eslint/js": "^9.30.0",
|
|
14
|
-
"@moonrepo/cli": "^1.32.1",
|
|
15
14
|
"eslint": "^9.30.0",
|
|
16
15
|
"knip": "^5.61.3",
|
|
17
16
|
"typedoc": "^0.28.7",
|
|
@@ -20,7 +19,7 @@
|
|
|
20
19
|
"typescript-eslint": "^8.35.0"
|
|
21
20
|
},
|
|
22
21
|
"dependencies": {
|
|
23
|
-
"@tari-project/tarijs-types": "^0.
|
|
22
|
+
"@tari-project/tarijs-types": "^0.14.0"
|
|
24
23
|
},
|
|
25
24
|
"scripts": {
|
|
26
25
|
"docs": "typedoc",
|
|
@@ -5,7 +5,8 @@ import { TransactionRequest } from "./TransactionRequest";
|
|
|
5
5
|
import { Amount, Network, TransactionArg } from "@tari-project/tarijs-types";
|
|
6
6
|
import {
|
|
7
7
|
ComponentAddress,
|
|
8
|
-
|
|
8
|
+
MinotariBurnClaimProof,
|
|
9
|
+
ClaimBurnOutputData,
|
|
9
10
|
ConfidentialWithdrawProof,
|
|
10
11
|
Instruction,
|
|
11
12
|
ResourceAddress,
|
|
@@ -187,7 +188,7 @@ export interface Builder {
|
|
|
187
188
|
* - If `withdraw_proof` is required by the burn process, it must be included.
|
|
188
189
|
* - This method should be used only when recovering burned confidential resources.
|
|
189
190
|
*/
|
|
190
|
-
claimBurn(claim:
|
|
191
|
+
claimBurn(claim: MinotariBurnClaimProof, output_data: ClaimBurnOutputData): this;
|
|
191
192
|
|
|
192
193
|
addInput(inputObject: SubstateRequirement): this;
|
|
193
194
|
|
|
@@ -346,7 +347,7 @@ export class TransactionBuilder implements Builder {
|
|
|
346
347
|
|
|
347
348
|
return this.addInstruction({
|
|
348
349
|
CreateAccount: {
|
|
349
|
-
|
|
350
|
+
owner_public_key: ownerPublicKey,
|
|
350
351
|
owner_rule: null, // Custom owner rule is not set by default
|
|
351
352
|
access_rules: null, // Custom access rules are not set by default
|
|
352
353
|
workspace_id,
|
|
@@ -364,10 +365,11 @@ export class TransactionBuilder implements Builder {
|
|
|
364
365
|
});
|
|
365
366
|
}
|
|
366
367
|
|
|
367
|
-
|
|
368
|
+
public claimBurn(claim: MinotariBurnClaimProof, output_data: ClaimBurnOutputData): this {
|
|
368
369
|
return this.addInstruction({
|
|
369
370
|
ClaimBurn: {
|
|
370
371
|
claim,
|
|
372
|
+
output_data,
|
|
371
373
|
},
|
|
372
374
|
});
|
|
373
375
|
}
|
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
GetEpochManagerStatsResponse,
|
|
3
|
-
GetNonFungibleCollectionsResponse,
|
|
4
|
-
GetNonFungibleCountRequest,
|
|
5
|
-
GetNonFungibleCountResponse,
|
|
6
3
|
GetNonFungiblesRequest,
|
|
7
4
|
GetNonFungiblesResponse,
|
|
8
|
-
GetRelatedTransactionsRequest,
|
|
9
|
-
GetRelatedTransactionsResponse,
|
|
10
5
|
GetTemplateDefinitionRequest,
|
|
11
6
|
GetTemplateDefinitionResponse,
|
|
12
7
|
IndexerGetIdentityResponse,
|
|
@@ -92,22 +87,10 @@ export class IndexerProviderClient {
|
|
|
92
87
|
return this.__invokeRpc("get_transaction_result", params);
|
|
93
88
|
}
|
|
94
89
|
|
|
95
|
-
public getSubstateTransactions(params: GetRelatedTransactionsRequest): Promise<GetRelatedTransactionsResponse> {
|
|
96
|
-
return this.__invokeRpc("get_substate_transactions", params);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
90
|
public getNonFungibles(params: GetNonFungiblesRequest): Promise<GetNonFungiblesResponse> {
|
|
100
91
|
return this.__invokeRpc("get_non_fungibles", params);
|
|
101
92
|
}
|
|
102
93
|
|
|
103
|
-
public getNonFungibleCollections(): Promise<GetNonFungibleCollectionsResponse> {
|
|
104
|
-
return this.__invokeRpc("get_non_fungible_collections");
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
public getNonFungibleCount(params: GetNonFungibleCountRequest): Promise<GetNonFungibleCountResponse> {
|
|
108
|
-
return this.__invokeRpc("get_non_fungible_count", params);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
94
|
public getEpochManagerStats(): Promise<GetEpochManagerStatsResponse> {
|
|
112
95
|
return this.__invokeRpc("get_epoch_manager_stats");
|
|
113
96
|
}
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
ListSubstatesResponse,
|
|
11
11
|
AccountData,
|
|
12
12
|
ListSubstatesRequest,
|
|
13
|
-
GetTransactionResultResponse,
|
|
13
|
+
GetTransactionResultResponse, ListNftsResponse, ListNftsRequest,
|
|
14
14
|
} from "@tari-project/tarijs-types";
|
|
15
15
|
import { MetaMaskInpageProvider } from "@metamask/providers";
|
|
16
16
|
import { connectSnap, getSnap, isFlask, Snap } from "./utils";
|
|
@@ -19,8 +19,6 @@ import {
|
|
|
19
19
|
AccountsListRequest,
|
|
20
20
|
AccountsListResponse,
|
|
21
21
|
ConfidentialViewVaultBalanceRequest,
|
|
22
|
-
ListAccountNftRequest,
|
|
23
|
-
ListAccountNftResponse,
|
|
24
22
|
WalletGetInfoResponse,
|
|
25
23
|
} from "@tari-project/typescript-bindings";
|
|
26
24
|
|
|
@@ -82,8 +80,8 @@ export class MetamaskTariSigner implements TariSigner {
|
|
|
82
80
|
})) as any;
|
|
83
81
|
return {
|
|
84
82
|
account_id,
|
|
85
|
-
|
|
86
|
-
|
|
83
|
+
component_address: res.address,
|
|
84
|
+
wallet_address: res.public_key,
|
|
87
85
|
vaults: [],
|
|
88
86
|
};
|
|
89
87
|
}
|
|
@@ -213,8 +211,8 @@ export class MetamaskTariSigner implements TariSigner {
|
|
|
213
211
|
return resp as T;
|
|
214
212
|
}
|
|
215
213
|
|
|
216
|
-
public async getNftsList(req:
|
|
217
|
-
const resp = (await this.metamaskRequest("getNftsList", req)) as
|
|
214
|
+
public async getNftsList(req: ListNftsRequest): Promise<ListNftsResponse> {
|
|
215
|
+
const resp = (await this.metamaskRequest("getNftsList", req)) as ListNftsResponse;
|
|
218
216
|
return resp;
|
|
219
217
|
}
|
|
220
218
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tari-project/react-mui-connect-button",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"description": "React component to connect your website to the Tari Ootle Wallet",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
"@tari-project/tari-provider": "workspace:*",
|
|
20
20
|
"@tari-project/tari-signer": "workspace:^",
|
|
21
21
|
"@tari-project/wallet-connect-signer": "workspace:^",
|
|
22
|
-
"@tari-project/wallet-daemon-signer": "workspace:^"
|
|
22
|
+
"@tari-project/wallet-daemon-signer": "workspace:^",
|
|
23
|
+
"@tari-project/tari-universe-signer": "workspace:^"
|
|
23
24
|
},
|
|
24
25
|
"peerDependencies": {
|
|
25
26
|
"@mui/icons-material": "^7",
|
|
@@ -6,6 +6,7 @@ import { TariSigner } from "@tari-project/tari-signer";
|
|
|
6
6
|
import { TariLogoWhite } from "./Logos";
|
|
7
7
|
import { WalletDaemonFetchParameters } from "@tari-project/wallet-daemon-signer";
|
|
8
8
|
import { WalletConnectParameters } from "@tari-project/wallet-connect-signer";
|
|
9
|
+
import { TariUniverseSignerParameters } from "@tari-project/tari-universe-signer";
|
|
9
10
|
|
|
10
11
|
export interface TariConnectButtonProps {
|
|
11
12
|
isConnected: boolean;
|
|
@@ -13,6 +14,7 @@ export interface TariConnectButtonProps {
|
|
|
13
14
|
onConnected?: (signer: TariSigner) => void;
|
|
14
15
|
walletConnectParams?: WalletConnectParameters;
|
|
15
16
|
walletDaemonParams?: WalletDaemonFetchParameters;
|
|
17
|
+
tariUniverseParams?: TariUniverseSignerParameters;
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
export function TariConnectButton(props: TariConnectButtonProps) {
|
|
@@ -44,6 +46,7 @@ export function TariConnectButton(props: TariConnectButtonProps) {
|
|
|
44
46
|
onConnected={props.onConnected}
|
|
45
47
|
walletConnectParams={props.walletConnectParams}
|
|
46
48
|
walletDaemonParams={props.walletDaemonParams}
|
|
49
|
+
tariUniverseParams={props.tariUniverseParams}
|
|
47
50
|
/>
|
|
48
51
|
</>
|
|
49
52
|
);
|
|
@@ -8,17 +8,19 @@ import { WalletDaemonTariSigner, WalletDaemonFetchParameters } from "@tari-proje
|
|
|
8
8
|
import { ReactElement, useState } from "react";
|
|
9
9
|
import { WalletConnectTariSigner, WalletConnectParameters } from "@tari-project/wallet-connect-signer";
|
|
10
10
|
import { TariLogo, WalletConnectLogo } from "./Logos";
|
|
11
|
+
import { TariUniverseSigner, TariUniverseSignerParameters } from "@tari-project/tari-universe-signer";
|
|
11
12
|
|
|
12
13
|
export interface WalletSelectionProps {
|
|
13
14
|
open: boolean;
|
|
14
15
|
onConnected?: (signer: TariSigner) => void;
|
|
15
16
|
walletConnectParams?: WalletConnectParameters;
|
|
16
17
|
walletDaemonParams?: WalletDaemonFetchParameters;
|
|
18
|
+
tariUniverseParams?: TariUniverseSignerParameters;
|
|
17
19
|
onClose: () => void;
|
|
18
20
|
}
|
|
19
21
|
|
|
20
22
|
export function TariWalletSelectionDialog(props: WalletSelectionProps): ReactElement {
|
|
21
|
-
const { onClose, open, onConnected, walletConnectParams, walletDaemonParams } = props;
|
|
23
|
+
const { onClose, open, onConnected, walletConnectParams, walletDaemonParams, tariUniverseParams } = props;
|
|
22
24
|
const [isBusy, setIsBusy] = useState(false);
|
|
23
25
|
const [error, setError] = useState<string | null>(null);
|
|
24
26
|
|
|
@@ -58,6 +60,15 @@ export function TariWalletSelectionDialog(props: WalletSelectionProps): ReactEle
|
|
|
58
60
|
}
|
|
59
61
|
};
|
|
60
62
|
|
|
63
|
+
const onTariUniverseClick = async () => {
|
|
64
|
+
if (!tariUniverseParams) {
|
|
65
|
+
throw new Error("Tari Universe Signer parameters were not provided.");
|
|
66
|
+
}
|
|
67
|
+
const tuSigner = new TariUniverseSigner(tariUniverseParams);
|
|
68
|
+
onConnected?.(tuSigner);
|
|
69
|
+
handleClose();
|
|
70
|
+
};
|
|
71
|
+
|
|
61
72
|
return (
|
|
62
73
|
<Dialog fullWidth={true} onClose={handleClose} open={open}>
|
|
63
74
|
<Box sx={{ padding: 4, borderRadius: 4 }}>
|
|
@@ -99,6 +110,16 @@ export function TariWalletSelectionDialog(props: WalletSelectionProps): ReactEle
|
|
|
99
110
|
></WalletConnectionMethodCard>
|
|
100
111
|
</Grid>
|
|
101
112
|
)}
|
|
113
|
+
|
|
114
|
+
{tariUniverseParams && (
|
|
115
|
+
<Grid container rowSpacing={1} columnSpacing={{ xs: 4 }}>
|
|
116
|
+
<WalletConnectionMethodCard
|
|
117
|
+
logo={<TariLogo />}
|
|
118
|
+
text="Tari Universe"
|
|
119
|
+
callback={onTariUniverseClick}
|
|
120
|
+
></WalletConnectionMethodCard>
|
|
121
|
+
</Grid>
|
|
122
|
+
)}
|
|
102
123
|
</Grid>
|
|
103
124
|
</Box>
|
|
104
125
|
</Dialog>
|
|
@@ -8,9 +8,7 @@
|
|
|
8
8
|
"outDir": "./dist",
|
|
9
9
|
"rootDir": "./src"
|
|
10
10
|
},
|
|
11
|
-
"include": [
|
|
12
|
-
"src/**/*"
|
|
13
|
-
],
|
|
11
|
+
"include": ["src/**/*"],
|
|
14
12
|
"references": [
|
|
15
13
|
{
|
|
16
14
|
"path": "../permissions"
|
|
@@ -26,6 +24,9 @@
|
|
|
26
24
|
},
|
|
27
25
|
{
|
|
28
26
|
"path": "../walletconnect"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"path": "../tari_universe"
|
|
29
30
|
}
|
|
30
31
|
]
|
|
31
32
|
}
|
|
@@ -3,8 +3,6 @@ import type {
|
|
|
3
3
|
AccountsListRequest,
|
|
4
4
|
AccountsListResponse,
|
|
5
5
|
ConfidentialViewVaultBalanceRequest,
|
|
6
|
-
ListAccountNftRequest,
|
|
7
|
-
ListAccountNftResponse,
|
|
8
6
|
WalletGetInfoResponse,
|
|
9
7
|
} from "@tari-project/typescript-bindings";
|
|
10
8
|
import {
|
|
@@ -17,6 +15,8 @@ import {
|
|
|
17
15
|
Substate,
|
|
18
16
|
ListSubstatesResponse,
|
|
19
17
|
ListSubstatesRequest,
|
|
18
|
+
ListNftsRequest,
|
|
19
|
+
ListNftsResponse,
|
|
20
20
|
} from "@tari-project/tarijs-types";
|
|
21
21
|
|
|
22
22
|
export interface TariSigner {
|
|
@@ -32,6 +32,6 @@ export interface TariSigner {
|
|
|
32
32
|
getPublicKey(branch: string, index: number): Promise<string>;
|
|
33
33
|
getConfidentialVaultBalances(req: ConfidentialViewVaultBalanceRequest): Promise<VaultBalances>;
|
|
34
34
|
listSubstates(req: ListSubstatesRequest): Promise<ListSubstatesResponse>;
|
|
35
|
-
getNftsList(req:
|
|
35
|
+
getNftsList(req: ListNftsRequest): Promise<ListNftsResponse>;
|
|
36
36
|
getWalletInfo(): Promise<WalletGetInfoResponse>;
|
|
37
37
|
}
|
|
@@ -9,6 +9,8 @@ import {
|
|
|
9
9
|
ListSubstatesRequest,
|
|
10
10
|
GetTransactionResultResponse,
|
|
11
11
|
ListAccountNftFromBalancesRequest,
|
|
12
|
+
ListNftsRequest,
|
|
13
|
+
ListNftsResponse,
|
|
12
14
|
} from "@tari-project/tarijs-types";
|
|
13
15
|
import { SignerRequest, SignerMethodNames, SignerReturnType, TariUniverseSignerParameters, WindowSize } from "./types";
|
|
14
16
|
import { sendSignerCall } from "./utils";
|
|
@@ -19,10 +21,9 @@ import {
|
|
|
19
21
|
AccountsListRequest,
|
|
20
22
|
AccountsListResponse,
|
|
21
23
|
ConfidentialViewVaultBalanceRequest,
|
|
22
|
-
ListAccountNftRequest,
|
|
23
|
-
ListAccountNftResponse,
|
|
24
24
|
WalletGetInfoResponse,
|
|
25
25
|
} from "@tari-project/typescript-bindings";
|
|
26
|
+
import { MessageType } from "./useIframeMessage";
|
|
26
27
|
|
|
27
28
|
export class TariUniverseSigner implements TariSigner {
|
|
28
29
|
public signerName = "TariUniverse";
|
|
@@ -30,8 +31,8 @@ export class TariUniverseSigner implements TariSigner {
|
|
|
30
31
|
|
|
31
32
|
public constructor(public params: TariUniverseSignerParameters) {
|
|
32
33
|
const filterResizeEvent = function (event: MessageEvent) {
|
|
33
|
-
if (event.data && event.data.type ===
|
|
34
|
-
const resizeEvent = new CustomEvent(
|
|
34
|
+
if (event.data && event.data.type === MessageType.RESIZE) {
|
|
35
|
+
const resizeEvent = new CustomEvent(MessageType.RESIZE, {
|
|
35
36
|
detail: { width: event.data.width, height: event.data.height },
|
|
36
37
|
});
|
|
37
38
|
window.dispatchEvent(resizeEvent);
|
|
@@ -92,6 +93,7 @@ export class TariUniverseSigner implements TariSigner {
|
|
|
92
93
|
}
|
|
93
94
|
|
|
94
95
|
public async getAccount(): Promise<AccountData> {
|
|
96
|
+
console.warn("ELOSZKI Z GET ACCOUNT");
|
|
95
97
|
return this.sendRequest({ methodName: "getAccount", args: [] });
|
|
96
98
|
}
|
|
97
99
|
|
|
@@ -131,11 +133,11 @@ export class TariUniverseSigner implements TariSigner {
|
|
|
131
133
|
return this.sendRequest({ methodName: "getTemplateDefinition", args: [template_address] });
|
|
132
134
|
}
|
|
133
135
|
|
|
134
|
-
public async getNftsList(req:
|
|
136
|
+
public async getNftsList(req: ListNftsRequest): Promise<ListNftsResponse> {
|
|
135
137
|
return this.sendRequest({ methodName: "getNftsList", args: [req] });
|
|
136
138
|
}
|
|
137
139
|
|
|
138
|
-
public async getNftsFromAccountBalances(req: ListAccountNftFromBalancesRequest): Promise<
|
|
140
|
+
public async getNftsFromAccountBalances(req: ListAccountNftFromBalancesRequest): Promise<ListNftsResponse> {
|
|
139
141
|
return this.sendRequest({ methodName: "getNftsFromAccountBalances", args: [req] });
|
|
140
142
|
}
|
|
141
143
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { TariPermissions } from "@tari-project/tari-permissions";
|
|
2
2
|
import { TariUniverseSigner } from "./signer";
|
|
3
|
+
import { MessageType } from "./useIframeMessage";
|
|
3
4
|
|
|
4
5
|
export type TariUniverseSignerParameters = {
|
|
5
6
|
permissions: TariPermissions;
|
|
@@ -28,7 +29,7 @@ export type SignerRequest<T extends SignerMethodNames> = {
|
|
|
28
29
|
|
|
29
30
|
export type SignerResponse<T extends SignerMethodNames> = {
|
|
30
31
|
id: number;
|
|
31
|
-
type:
|
|
32
|
+
type: MessageType.SIGNER_CALL;
|
|
32
33
|
result: SignerReturnType<T>;
|
|
33
34
|
resultError?: string;
|
|
34
35
|
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
export enum MessageType {
|
|
2
|
+
SIGNER_CALL = "SIGNER_CALL",
|
|
3
|
+
RESIZE = "resize",
|
|
4
|
+
SET_LANGUAGE = "SET_LANGUAGE",
|
|
5
|
+
SET_THEME = "SET_THEME",
|
|
6
|
+
GET_INIT_CONFIG = "GET_INIT_CONFIG",
|
|
7
|
+
OPEN_EXTERNAL_LINK = "OPEN_EXTERNAL_LINK",
|
|
8
|
+
ERROR = "ERROR",
|
|
9
|
+
NOTIFICATION = "NOTIFICATION",
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
interface SignerCallMessage {
|
|
13
|
+
type: MessageType.SIGNER_CALL;
|
|
14
|
+
payload: {
|
|
15
|
+
id: number;
|
|
16
|
+
methodName: string;
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
18
|
+
args: any[];
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
interface ResizeMessage {
|
|
23
|
+
type: MessageType.RESIZE;
|
|
24
|
+
width: number;
|
|
25
|
+
height: number;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
interface SetLanguageMessage {
|
|
29
|
+
type: MessageType.SET_LANGUAGE;
|
|
30
|
+
payload: {
|
|
31
|
+
language: string;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
interface SetThemeMessage {
|
|
36
|
+
type: MessageType.SET_THEME;
|
|
37
|
+
payload: {
|
|
38
|
+
theme: string;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
interface GetInitConfigMessage {
|
|
43
|
+
type: MessageType.GET_INIT_CONFIG;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
interface OpenLinkMessage {
|
|
47
|
+
type: MessageType.OPEN_EXTERNAL_LINK;
|
|
48
|
+
payload: {
|
|
49
|
+
url: string;
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
type ErrorMessage = {
|
|
54
|
+
type: MessageType.ERROR;
|
|
55
|
+
payload: {
|
|
56
|
+
message: string;
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
interface EmitNotificationMessage {
|
|
61
|
+
type: MessageType.NOTIFICATION;
|
|
62
|
+
payload: {
|
|
63
|
+
notification: string;
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export type IframeMessage =
|
|
68
|
+
| SignerCallMessage
|
|
69
|
+
| ResizeMessage
|
|
70
|
+
| SetLanguageMessage
|
|
71
|
+
| SetThemeMessage
|
|
72
|
+
| GetInitConfigMessage
|
|
73
|
+
| OpenLinkMessage
|
|
74
|
+
| ErrorMessage
|
|
75
|
+
| EmitNotificationMessage;
|
|
76
|
+
|
|
77
|
+
// Post a message to the parent window
|
|
78
|
+
export function postToParentIframe(message: IframeMessage, targetOrigin: string = "*") {
|
|
79
|
+
if (window.parent && message.type) {
|
|
80
|
+
window.parent.postMessage(message, targetOrigin);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SignerMethodNames, SignerRequest, SignerResponse, SignerReturnType } from "./types";
|
|
2
|
+
import { MessageType, postToParentIframe } from "./useIframeMessage";
|
|
2
3
|
|
|
3
4
|
export function sendSignerCall<MethodName extends SignerMethodNames>(
|
|
4
5
|
req: Omit<SignerRequest<MethodName>, "id">,
|
|
@@ -10,7 +11,7 @@ export function sendSignerCall<MethodName extends SignerMethodNames>(
|
|
|
10
11
|
window.removeEventListener("message", event_ref);
|
|
11
12
|
reject(resp.data.resultError);
|
|
12
13
|
}
|
|
13
|
-
if (resp && resp.data && resp.data.id && resp.data.id === id && resp.data.type ===
|
|
14
|
+
if (resp && resp.data && resp.data.id && resp.data.id === id && resp.data.type === MessageType.SIGNER_CALL) {
|
|
14
15
|
window.removeEventListener("message", event_ref);
|
|
15
16
|
resolve(resp.data.result);
|
|
16
17
|
}
|
|
@@ -18,6 +19,9 @@ export function sendSignerCall<MethodName extends SignerMethodNames>(
|
|
|
18
19
|
|
|
19
20
|
window.addEventListener("message", event_ref, false);
|
|
20
21
|
|
|
21
|
-
|
|
22
|
+
postToParentIframe({
|
|
23
|
+
type: MessageType.SIGNER_CALL,
|
|
24
|
+
payload: { args: req.args, methodName: req.methodName, id: id },
|
|
25
|
+
});
|
|
22
26
|
});
|
|
23
27
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CompressedElgamalVerifiableBalance } from "@tari-project/typescript-bindings";
|
|
2
2
|
|
|
3
3
|
export interface ConfidentialOutput {
|
|
4
4
|
commitment: string;
|
|
5
5
|
stealthPublicNonce: string;
|
|
6
6
|
encrypted_data: Array<number>;
|
|
7
7
|
minimumValuePromise: number;
|
|
8
|
-
viewableBalance?:
|
|
8
|
+
viewableBalance?: CompressedElgamalVerifiableBalance;
|
|
9
9
|
}
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
SubstateDiff,
|
|
11
11
|
SubstateType,
|
|
12
12
|
TransactionReceipt,
|
|
13
|
-
|
|
13
|
+
ClaimedOutputTombstone,
|
|
14
14
|
ValidatorFeePool,
|
|
15
15
|
PublishedTemplate,
|
|
16
16
|
ValidatorFeeWithdrawal,
|
|
@@ -290,7 +290,7 @@ export type AnySubstate =
|
|
|
290
290
|
| ComponentHeader
|
|
291
291
|
| Resource
|
|
292
292
|
| Vault
|
|
293
|
-
|
|
|
293
|
+
| ClaimedOutputTombstone
|
|
294
294
|
| NonFungible
|
|
295
295
|
| TransactionReceipt
|
|
296
296
|
| ValidatorFeePool
|
|
@@ -12,19 +12,11 @@ import {
|
|
|
12
12
|
} from "@tari-project/typescript-bindings";
|
|
13
13
|
import { UpSubstates } from "../SubstateDiff";
|
|
14
14
|
|
|
15
|
-
function isOfType<T extends object>(obj: T, key: keyof T): boolean {
|
|
16
|
-
return obj !== null && typeof obj === "object" && key in obj;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
15
|
export const txResultCheck = {
|
|
20
16
|
isAccept: (result: FinalizeResult) => {
|
|
21
17
|
return "Accept" in result.result;
|
|
22
18
|
},
|
|
23
19
|
|
|
24
|
-
isVaultId: (substateId: SubstateId): substateId is { Vault: VaultId } => {
|
|
25
|
-
return isOfType(substateId, "Vault" as keyof SubstateId);
|
|
26
|
-
},
|
|
27
|
-
|
|
28
20
|
isVaultSubstate: (substate: SubstateValue): substate is { Vault: Vault } => {
|
|
29
21
|
return "Vault" in substate;
|
|
30
22
|
},
|
|
@@ -23,16 +23,18 @@ export { ListAccountNftFromBalancesRequest } from "./ListAccountNftFromBalancesR
|
|
|
23
23
|
export { Network } from "./network";
|
|
24
24
|
export {
|
|
25
25
|
AccountData,
|
|
26
|
+
GetSubstateRequest,
|
|
27
|
+
ListNftsRequest,
|
|
28
|
+
ListNftsResponse,
|
|
26
29
|
ListSubstatesRequest,
|
|
27
30
|
ListSubstatesResponse,
|
|
31
|
+
ReqSubstate,
|
|
28
32
|
SubmitTransactionRequest,
|
|
29
33
|
Substate,
|
|
30
34
|
SubstateMetadata,
|
|
31
|
-
ReqSubstate,
|
|
32
35
|
TemplateDefinition,
|
|
33
36
|
VaultBalances,
|
|
34
37
|
VaultData,
|
|
35
|
-
GetSubstateRequest,
|
|
36
38
|
} from "./signer";
|
|
37
39
|
|
|
38
40
|
export {
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
SubstateType,
|
|
3
|
+
TemplateDef,
|
|
4
|
+
UnsignedTransactionV1,
|
|
5
|
+
ComponentAddress,
|
|
6
|
+
NonFungibleToken,
|
|
7
|
+
OotleAddress,
|
|
8
|
+
} from "@tari-project/typescript-bindings";
|
|
2
9
|
|
|
3
10
|
export type SubstateMetadata = {
|
|
4
11
|
substate_id: string;
|
|
@@ -20,8 +27,8 @@ export type SubmitTransactionRequest = {
|
|
|
20
27
|
|
|
21
28
|
export interface AccountData {
|
|
22
29
|
account_id: number;
|
|
23
|
-
|
|
24
|
-
|
|
30
|
+
component_address: ComponentAddress;
|
|
31
|
+
wallet_address: OotleAddress;
|
|
25
32
|
vaults: VaultData[];
|
|
26
33
|
}
|
|
27
34
|
|
|
@@ -63,3 +70,13 @@ export type GetSubstateRequest = {
|
|
|
63
70
|
substate_address: string;
|
|
64
71
|
version: number | null;
|
|
65
72
|
};
|
|
73
|
+
|
|
74
|
+
export type ListNftsRequest = {
|
|
75
|
+
accountAddress: ComponentAddress;
|
|
76
|
+
limit: number | null;
|
|
77
|
+
offset: number | null;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export type ListNftsResponse = {
|
|
81
|
+
nfts: Array<NonFungibleToken>
|
|
82
|
+
};
|
|
@@ -74,16 +74,16 @@ export class WalletDaemonTariProvider implements TariProvider {
|
|
|
74
74
|
|
|
75
75
|
async getSubstate(req: GetSubstateRequest): Promise<Substate> {
|
|
76
76
|
// TODO: Substate address cannot be converted to SubstateId directly - Perhaps we need to change the provider interface
|
|
77
|
-
const {
|
|
78
|
-
if (!
|
|
77
|
+
const { substate_from_remote } = await this.client.substatesGet({ substate_id: req.substate_address });
|
|
78
|
+
if (!substate_from_remote) {
|
|
79
79
|
throw new Error(`Substate not found for address: ${req.substate_address}`);
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
return {
|
|
83
|
-
value:
|
|
83
|
+
value: substate_from_remote?.substate,
|
|
84
84
|
address: {
|
|
85
85
|
substate_id: req.substate_address,
|
|
86
|
-
version:
|
|
86
|
+
version: substate_from_remote?.version || 0,
|
|
87
87
|
},
|
|
88
88
|
};
|
|
89
89
|
}
|
|
@@ -14,6 +14,8 @@ import {
|
|
|
14
14
|
Substate,
|
|
15
15
|
ListSubstatesResponse,
|
|
16
16
|
ListSubstatesRequest,
|
|
17
|
+
ListNftsResponse,
|
|
18
|
+
ListNftsRequest,
|
|
17
19
|
} from "@tari-project/tarijs-types";
|
|
18
20
|
import {
|
|
19
21
|
AccountGetResponse,
|
|
@@ -21,8 +23,6 @@ import {
|
|
|
21
23
|
AccountsListResponse,
|
|
22
24
|
ConfidentialViewVaultBalanceRequest,
|
|
23
25
|
KeyBranch,
|
|
24
|
-
ListAccountNftRequest,
|
|
25
|
-
ListAccountNftResponse,
|
|
26
26
|
substateIdToString,
|
|
27
27
|
SubstatesListRequest,
|
|
28
28
|
WalletGetInfoResponse,
|
|
@@ -125,14 +125,14 @@ export class WalletDaemonTariSigner implements TariSigner {
|
|
|
125
125
|
public async createFreeTestCoins(): Promise<AccountData> {
|
|
126
126
|
const res = await this.client.createFreeTestCoins({
|
|
127
127
|
account: { Name: "template_web" },
|
|
128
|
-
amount:
|
|
128
|
+
amount: 1000_000_000,
|
|
129
129
|
max_fee: null,
|
|
130
|
-
key_id: 0,
|
|
131
130
|
});
|
|
132
131
|
return {
|
|
133
132
|
account_id: res.account.key_index,
|
|
134
|
-
|
|
135
|
-
|
|
133
|
+
component_address: res.account.component_address,
|
|
134
|
+
wallet_address: res.address,
|
|
135
|
+
// TODO: API for fetching vaults by account
|
|
136
136
|
vaults: [],
|
|
137
137
|
};
|
|
138
138
|
}
|
|
@@ -153,8 +153,8 @@ export class WalletDaemonTariSigner implements TariSigner {
|
|
|
153
153
|
|
|
154
154
|
return {
|
|
155
155
|
account_id: account.key_index,
|
|
156
|
-
address,
|
|
157
|
-
public_key,
|
|
156
|
+
component_address: address,
|
|
157
|
+
wallet_address: public_key,
|
|
158
158
|
// TODO: should be vaults not resources
|
|
159
159
|
vaults: balances.map((b: any) => ({
|
|
160
160
|
type: b.resource_type,
|
|
@@ -181,16 +181,16 @@ export class WalletDaemonTariSigner implements TariSigner {
|
|
|
181
181
|
}
|
|
182
182
|
|
|
183
183
|
public async getSubstate(substateId: string): Promise<Substate> {
|
|
184
|
-
const {
|
|
185
|
-
if (!
|
|
184
|
+
const { substate_from_remote } = await this.client.substatesGet({ substate_id: substateId });
|
|
185
|
+
if (!substate_from_remote) {
|
|
186
186
|
throw new Error(`Substate not found for address: ${substateId}`);
|
|
187
187
|
}
|
|
188
188
|
|
|
189
189
|
return {
|
|
190
|
-
value:
|
|
190
|
+
value: substate_from_remote?.substate,
|
|
191
191
|
address: {
|
|
192
192
|
substate_id: substateId,
|
|
193
|
-
version:
|
|
193
|
+
version: substate_from_remote?.version || 0,
|
|
194
194
|
},
|
|
195
195
|
};
|
|
196
196
|
}
|
|
@@ -261,7 +261,7 @@ export class WalletDaemonTariSigner implements TariSigner {
|
|
|
261
261
|
} as SubstatesListRequest);
|
|
262
262
|
|
|
263
263
|
const substates = resp.substates.map((s: any) => ({
|
|
264
|
-
substate_id:
|
|
264
|
+
substate_id: substateIdToString(s.substate_id),
|
|
265
265
|
module_name: s.module_name,
|
|
266
266
|
version: s.version,
|
|
267
267
|
template_address: s.template_address,
|
|
@@ -270,7 +270,7 @@ export class WalletDaemonTariSigner implements TariSigner {
|
|
|
270
270
|
return { substates };
|
|
271
271
|
}
|
|
272
272
|
|
|
273
|
-
public async getNftsList(req:
|
|
273
|
+
public async getNftsList(req: ListNftsRequest): Promise<ListNftsResponse> {
|
|
274
274
|
return await this.client.nftsList(req);
|
|
275
275
|
}
|
|
276
276
|
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
AccountData,
|
|
13
13
|
ListSubstatesResponse,
|
|
14
14
|
ListSubstatesRequest,
|
|
15
|
-
SubmitTransactionResponse,
|
|
15
|
+
SubmitTransactionResponse, ListNftsResponse, ListNftsRequest,
|
|
16
16
|
} from "@tari-project/tarijs-types";
|
|
17
17
|
import {
|
|
18
18
|
AccountGetResponse,
|
|
@@ -20,8 +20,6 @@ import {
|
|
|
20
20
|
AccountsListResponse,
|
|
21
21
|
ConfidentialViewVaultBalanceRequest,
|
|
22
22
|
KeyBranch,
|
|
23
|
-
ListAccountNftRequest,
|
|
24
|
-
ListAccountNftResponse,
|
|
25
23
|
substateIdToString,
|
|
26
24
|
TransactionSubmitRequest,
|
|
27
25
|
WalletGetInfoResponse,
|
|
@@ -173,8 +171,8 @@ export class WalletConnectTariSigner implements TariSigner {
|
|
|
173
171
|
|
|
174
172
|
return {
|
|
175
173
|
account_id: account.key_index,
|
|
176
|
-
|
|
177
|
-
public_key,
|
|
174
|
+
component_address: account.address,
|
|
175
|
+
wallet_address: public_key,
|
|
178
176
|
// TODO: should be vaults not resources
|
|
179
177
|
vaults: balances.map((b: any) => ({
|
|
180
178
|
type: b.resource_type,
|
|
@@ -244,8 +242,8 @@ export class WalletConnectTariSigner implements TariSigner {
|
|
|
244
242
|
const res = await this.sendRequest(method, params);
|
|
245
243
|
return {
|
|
246
244
|
account_id: res.account.key_index,
|
|
247
|
-
|
|
248
|
-
|
|
245
|
+
component_address: (res.account.address as { Component: string }).Component,
|
|
246
|
+
wallet_address: res.public_key,
|
|
249
247
|
vaults: [],
|
|
250
248
|
};
|
|
251
249
|
}
|
|
@@ -305,15 +303,15 @@ export class WalletConnectTariSigner implements TariSigner {
|
|
|
305
303
|
return { balances: res.balances as unknown as Map<string, number | null> };
|
|
306
304
|
}
|
|
307
305
|
|
|
308
|
-
public async getNftsList(req:
|
|
306
|
+
public async getNftsList(req: ListNftsRequest): Promise<ListNftsResponse> {
|
|
309
307
|
const method = "tari_getNftsList";
|
|
310
308
|
const params = {
|
|
311
|
-
account: req.
|
|
309
|
+
account: req.accountAddress,
|
|
312
310
|
limit: req.limit,
|
|
313
311
|
offset: req.offset,
|
|
314
312
|
};
|
|
315
313
|
const res = await this.sendRequest(method, params);
|
|
316
|
-
return res as
|
|
314
|
+
return res as ListNftsResponse;
|
|
317
315
|
}
|
|
318
316
|
|
|
319
317
|
public async getWalletInfo(): Promise<WalletGetInfoResponse> {
|
package/pnpm-workspace.yaml
CHANGED
|
@@ -10,7 +10,7 @@ catalog:
|
|
|
10
10
|
vitest: ^3.0.4
|
|
11
11
|
vite: ^6.1.0
|
|
12
12
|
"@types/node": ^22.13.1
|
|
13
|
-
"@tari-project/typescript-bindings": ">=1.
|
|
13
|
+
"@tari-project/typescript-bindings": ">=1.17.0"
|
|
14
14
|
"@tari-project/wallet_jrpc_client": ^1.7.2
|
|
15
15
|
"@metamask/providers": ^18.2.0
|
|
16
16
|
"@walletconnect/universal-provider": 2.21.3
|