@tari-project/tarijs 0.2.0 → 0.3.1

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.
@@ -4,7 +4,7 @@ import { SubmitTransactionRequest, SubstateRequirement } from "../../providers/t
4
4
  import { Transaction, TransactionResult } from "../types";
5
5
  import { DownSubstates, UpSubstates } from "../types/SubstateDiff";
6
6
  import { SubmitTxResult } from "../types/TransactionResult";
7
- export declare function buildTransactionRequest(transaction: Transaction, accountId: number, requiredSubstates: SubstateRequirement[], inputRefs?: never[], isDryRun?: boolean): SubmitTransactionRequest;
7
+ export declare function buildTransactionRequest(transaction: Transaction, accountId: number, requiredSubstates: SubstateRequirement[], inputRefs?: never[], isDryRun?: boolean, network?: number, isSealSignerAuthorized?: boolean, detectInputsUseUnversioned?: boolean): SubmitTransactionRequest;
8
8
  export declare function submitAndWaitForTransaction(provider: TariProvider, req: SubmitTransactionRequest): Promise<SubmitTxResult>;
9
9
  export declare function waitForTransactionResult(provider: TariProvider | TariUniverseProvider, transactionId: string): Promise<TransactionResult>;
10
10
  export declare function getAcceptResultSubstates(txResult: TransactionResult): {
@@ -1,8 +1,9 @@
1
1
  import { TransactionStatus } from "../types";
2
- export function buildTransactionRequest(transaction, accountId, requiredSubstates, inputRefs = [], isDryRun = false) {
2
+ export function buildTransactionRequest(transaction, accountId, requiredSubstates, inputRefs = [], isDryRun = false, network = 0, isSealSignerAuthorized = true, detectInputsUseUnversioned = true) {
3
3
  return {
4
4
  //TODO refactor SubTxReq type to not use 'object[]' and types match
5
5
  // https://github.com/tari-project/tari.js/issues/25
6
+ network,
6
7
  account_id: accountId,
7
8
  instructions: transaction.instructions,
8
9
  fee_instructions: transaction.feeInstructions,
@@ -12,6 +13,8 @@ export function buildTransactionRequest(transaction, accountId, requiredSubstate
12
13
  is_dry_run: isDryRun,
13
14
  min_epoch: transaction.minEpoch ?? null,
14
15
  max_epoch: transaction.maxEpoch ?? null,
16
+ is_seal_signer_authorized: isSealSignerAuthorized,
17
+ detect_inputs_use_unversioned: detectInputsUseUnversioned,
15
18
  };
16
19
  }
17
20
  export async function submitAndWaitForTransaction(provider, req) {
@@ -1,8 +1,8 @@
1
- import { TransactionSignature } from "@tari-project/typescript-bindings";
2
1
  import { Instruction } from "./Instruction";
3
2
  import { SubstateRequirement } from "./SubstateRequirement";
4
3
  import { Epoch } from "./Epoch";
5
4
  import { VersionedSubstateId } from "./VersionedSubstateId";
5
+ import { TransactionSignature } from "./TransactionSignature";
6
6
  export interface Transaction {
7
7
  id: string;
8
8
  feeInstructions: Array<Instruction>;
@@ -1,6 +1,6 @@
1
1
  import { TariProvider } from "../index";
2
2
  import { SubmitTransactionRequest, TransactionResult, SubmitTransactionResponse, VaultBalances, TemplateDefinition, Substate, ListSubstatesResponse } from "../types";
3
- import { MetaMaskInpageProvider } from '@metamask/providers';
3
+ import { MetaMaskInpageProvider } from "@metamask/providers";
4
4
  import { Snap } from "./utils";
5
5
  import { Account } from "../types";
6
6
  import { SubstateType } from "@tari-project/typescript-bindings";
@@ -1,8 +1,8 @@
1
1
  import { TransactionStatus, } from "../types";
2
2
  import { connectSnap, getSnap, isFlask } from "./utils";
3
- export const MetamaskNotInstalled = 'METAMASK_NOT_INSTALLED';
4
- export const MetamaskIsNotFlask = 'METAMASK_IS_NOT_FLASK';
5
- export const TariSnapNotInstalled = 'TARI_SNAP_NOT_INSTALLED';
3
+ export const MetamaskNotInstalled = "METAMASK_NOT_INSTALLED";
4
+ export const MetamaskIsNotFlask = "METAMASK_IS_NOT_FLASK";
5
+ export const TariSnapNotInstalled = "TARI_SNAP_NOT_INSTALLED";
6
6
  export class MetamaskTariProvider {
7
7
  providerName = "Metamask";
8
8
  snapId;
@@ -41,32 +41,32 @@ export class MetamaskTariProvider {
41
41
  return this.metamaskConnected;
42
42
  }
43
43
  async createFreeTestCoins(account_id) {
44
- const res = await this.metamaskRequest('getFreeTestCoins', {
44
+ const res = (await this.metamaskRequest("getFreeTestCoins", {
45
45
  amount: 1000000,
46
46
  account_id,
47
- fee: 2000
48
- });
47
+ fee: 2000,
48
+ }));
49
49
  return {
50
50
  account_id,
51
51
  address: res.address,
52
52
  public_key: res.public_key,
53
- resources: []
53
+ resources: [],
54
54
  };
55
55
  }
56
56
  async getAccount() {
57
- return await this.metamaskRequest('getAccountData', { account_id: 0 });
57
+ return (await this.metamaskRequest("getAccountData", { account_id: 0 }));
58
58
  }
59
59
  async getSubstate(substate_address) {
60
- const { substate, address: substate_id, version } = await this.metamaskRequest('getSubstate', { substate_address });
60
+ const { substate, address: substate_id, version, } = await this.metamaskRequest("getSubstate", { substate_address });
61
61
  return { value: substate, address: { substate_id, version } };
62
62
  }
63
63
  async listSubstates(filter_by_template, filter_by_type, limit, offset) {
64
- const res = await this.metamaskRequest('listSubstates', {
64
+ const res = (await this.metamaskRequest("listSubstates", {
65
65
  filter_by_template,
66
66
  filter_by_type,
67
67
  limit,
68
68
  offset,
69
- });
69
+ }));
70
70
  return res;
71
71
  }
72
72
  async submitTransaction(req) {
@@ -77,7 +77,7 @@ export class MetamaskTariProvider {
77
77
  required_substates: req.required_substates || [],
78
78
  is_dry_run: req.is_dry_run,
79
79
  };
80
- const resp = await this.metamaskRequest('sendTransaction', params);
80
+ const resp = await this.metamaskRequest("sendTransaction", params);
81
81
  if (!resp) {
82
82
  throw new Error("Failed to submit transaction to metamask snap: empty response");
83
83
  }
@@ -88,7 +88,7 @@ export class MetamaskTariProvider {
88
88
  }
89
89
  async getTransactionResult(transactionId) {
90
90
  // This request returns the response from the indexer get_transaction_result request
91
- const resp = await this.metamaskRequest('getTransactionResult', { transaction_id: transactionId });
91
+ const resp = await this.metamaskRequest("getTransactionResult", { transaction_id: transactionId });
92
92
  if (!resp) {
93
93
  throw new Error("Failed to get transaction result from metamask snap: empty response");
94
94
  }
@@ -96,7 +96,7 @@ export class MetamaskTariProvider {
96
96
  return {
97
97
  transaction_id: transactionId,
98
98
  status: TransactionStatus.Pending,
99
- result: null
99
+ result: null,
100
100
  };
101
101
  }
102
102
  if (!resp?.result?.Finalized) {
@@ -106,28 +106,27 @@ export class MetamaskTariProvider {
106
106
  return {
107
107
  transaction_id: transactionId,
108
108
  status: newStatus,
109
- result: resp.result.Finalized.execution_result.finalize
109
+ result: resp.result.Finalized.execution_result.finalize,
110
110
  };
111
111
  }
112
112
  async getPublicKey(_branch, index) {
113
- const resp = await this.metamaskRequest('getPublicKey', { index });
113
+ const resp = await this.metamaskRequest("getPublicKey", { index });
114
114
  if (!resp) {
115
115
  throw new Error("Failed to get public key from metamask snap: empty response");
116
116
  }
117
117
  return resp.public_key;
118
118
  }
119
119
  async getConfidentialVaultBalances(viewKeyId, vaultId, min = null, max = null) {
120
- const res = await this.metamaskRequest('getConfidentialVaultBalances', {
120
+ const res = (await this.metamaskRequest("getConfidentialVaultBalances", {
121
121
  view_key_id: viewKeyId,
122
122
  vault_id: vaultId,
123
123
  minimum_expected_value: min,
124
124
  maximum_expected_value: max,
125
- });
125
+ }));
126
126
  return { balances: res };
127
127
  }
128
128
  getTemplateDefinition(template_address) {
129
- return this.metamaskRequest('getTemplateDefinition', { template_address })
130
- .then(resp => {
129
+ return this.metamaskRequest("getTemplateDefinition", { template_address }).then((resp) => {
131
130
  if (!resp) {
132
131
  throw new Error("Template not found");
133
132
  }
@@ -137,13 +136,13 @@ export class MetamaskTariProvider {
137
136
  async metamaskRequest(method, params) {
138
137
  console.log("Metamask request:", method, params);
139
138
  const resp = await this.metamask.request({
140
- method: 'wallet_invokeSnap',
139
+ method: "wallet_invokeSnap",
141
140
  params: {
142
141
  snapId: this.snapId,
143
142
  request: {
144
143
  method,
145
- params
146
- }
144
+ params,
145
+ },
147
146
  },
148
147
  });
149
148
  console.log("Metamask response:", resp);
@@ -1,3 +1,4 @@
1
+ import { sendProviderCall } from "./utils";
1
2
  export class TariUniverseProvider {
2
3
  params;
3
4
  providerName = "TariUniverse";
@@ -16,20 +17,7 @@ export class TariUniverseProvider {
16
17
  }
17
18
  async sendRequest(req) {
18
19
  const id = ++this.__id;
19
- return new Promise(function (resolve, reject) {
20
- const event_ref = function (resp) {
21
- if (resp.data.resultError) {
22
- window.removeEventListener("message", event_ref);
23
- reject(resp.data.resultError);
24
- }
25
- if (resp && resp.data && resp.data.id && resp.data.id == id && resp.data.type === "provider-call") {
26
- window.removeEventListener("message", event_ref);
27
- resolve(resp.data.result);
28
- }
29
- };
30
- window.addEventListener("message", event_ref, false);
31
- window.parent.postMessage({ ...req, id, type: "provider-call" }, "*");
32
- });
20
+ return sendProviderCall(req, id);
33
21
  }
34
22
  isConnected() {
35
23
  return true;
@@ -56,7 +44,20 @@ export class TariUniverseProvider {
56
44
  return this.sendRequest({ methodName: "requestParentSize", args: [] });
57
45
  }
58
46
  async getAccount() {
59
- return this.sendRequest({ methodName: "getAccount", args: [] });
47
+ const { account_id, address, public_key } = await this.sendRequest({ methodName: "getAccount", args: [] });
48
+ const { balances } = await this.getAccountBalances(address);
49
+ return {
50
+ account_id,
51
+ address,
52
+ public_key,
53
+ resources: balances.map((b) => ({
54
+ type: b.resource_type,
55
+ resource_address: b.resource_address,
56
+ balance: b.balance + b.confidential_balance,
57
+ vault_id: "Vault" in b.vault_address ? b.vault_address.Vault : b.vault_address,
58
+ token_symbol: b.token_symbol,
59
+ })),
60
+ };
60
61
  }
61
62
  async getAccountBalances(componentAddress) {
62
63
  return this.sendRequest({
@@ -0,0 +1,2 @@
1
+ import { ProviderMethodNames, ProviderRequest, ProviderReturnType } from "./types";
2
+ export declare function sendProviderCall<MethodName extends ProviderMethodNames>(req: Omit<ProviderRequest<MethodName>, "id">, id: number): Promise<ProviderReturnType<MethodName>>;
@@ -0,0 +1,16 @@
1
+ export function sendProviderCall(req, id) {
2
+ return new Promise((resolve, reject) => {
3
+ const event_ref = (resp) => {
4
+ if (resp.data.resultError) {
5
+ window.removeEventListener("message", event_ref);
6
+ reject(resp.data.resultError);
7
+ }
8
+ if (resp && resp.data && resp.data.id && resp.data.id === id && resp.data.type === "provider-call") {
9
+ window.removeEventListener("message", event_ref);
10
+ resolve(resp.data.result);
11
+ }
12
+ };
13
+ window.addEventListener("message", event_ref, false);
14
+ window.parent.postMessage({ ...req, id, type: "provider-call" }, "*");
15
+ });
16
+ }
@@ -10,6 +10,7 @@ export type SubstateRequirement = {
10
10
  version?: number | null;
11
11
  };
12
12
  export type SubmitTransactionRequest = {
13
+ network: number;
13
14
  account_id: number;
14
15
  instructions: object[];
15
16
  fee_instructions: object[];
@@ -19,6 +20,8 @@ export type SubmitTransactionRequest = {
19
20
  is_dry_run: boolean;
20
21
  min_epoch: number | null;
21
22
  max_epoch: number | null;
23
+ is_seal_signer_authorized: boolean;
24
+ detect_inputs_use_unversioned: boolean;
22
25
  };
23
26
  export type SubmitTransactionResponse = {
24
27
  transaction_id: string;
@@ -5,27 +5,35 @@ import { Account } from "../types";
5
5
  import { WalletDaemonClient, SubstateType } from "@tari-project/wallet_jrpc_client";
6
6
  export declare const WalletDaemonNotConnected = "WALLET_DAEMON_NOT_CONNECTED";
7
7
  export declare const Unsupported = "UNSUPPORTED";
8
- export type WalletDaemonParameters = {
9
- signalingServerUrl?: string;
8
+ export interface WalletDaemonBaseParameters {
10
9
  permissions: TariPermissions;
11
- optionalPermissions: TariPermissions;
10
+ optionalPermissions?: TariPermissions;
11
+ onConnection?: () => void;
12
+ }
13
+ export interface WalletDaemonParameters extends WalletDaemonBaseParameters {
14
+ signalingServerUrl?: string;
12
15
  webRtcConfig?: RTCConfiguration;
13
16
  name?: string;
14
- onConnection?: () => void;
15
- };
17
+ }
18
+ export interface WalletDaemonFetchParameters extends WalletDaemonBaseParameters {
19
+ serverUrl: string;
20
+ }
16
21
  export declare class WalletDaemonTariProvider implements TariProvider {
17
22
  providerName: string;
18
23
  params: WalletDaemonParameters;
19
24
  client: WalletDaemonClient;
20
25
  private constructor();
21
26
  static build(params: WalletDaemonParameters): Promise<WalletDaemonTariProvider>;
27
+ static buildFetchProvider(params: WalletDaemonFetchParameters): Promise<WalletDaemonTariProvider>;
28
+ private static buildPermissions;
29
+ private getWebRtcTransport;
22
30
  get token(): string | undefined;
23
31
  get tokenUrl(): string | undefined;
24
32
  isConnected(): boolean;
25
33
  createFreeTestCoins(): Promise<Account>;
26
34
  getAccount(): Promise<Account>;
27
35
  getAccountBalances(componentAddress: string): Promise<unknown>;
28
- getSubstate(substate_id: string): Promise<Substate>;
36
+ getSubstate(substateId: string): Promise<Substate>;
29
37
  submitTransaction(req: SubmitTransactionRequest): Promise<SubmitTransactionResponse>;
30
38
  getTransactionResult(transactionId: string): Promise<TransactionResult>;
31
39
  getPublicKey(branch: string, index: number): Promise<string>;
@@ -1,10 +1,11 @@
1
1
  import { TariPermissions, } from "./tari_permissions";
2
2
  import { TariConnection } from "./webrtc";
3
3
  import { TransactionStatus, } from "../types";
4
- import { WalletDaemonClient, stringToSubstateId, substateIdToString, } from "@tari-project/wallet_jrpc_client";
4
+ import { WalletDaemonClient, substateIdToString, } from "@tari-project/wallet_jrpc_client";
5
5
  import { WebRtcRpcTransport } from "./webrtc_transport";
6
6
  export const WalletDaemonNotConnected = 'WALLET_DAEMON_NOT_CONNECTED';
7
7
  export const Unsupported = 'UNSUPPORTED';
8
+ ;
8
9
  export class WalletDaemonTariProvider {
9
10
  providerName = "WalletDaemon";
10
11
  params;
@@ -14,10 +15,7 @@ export class WalletDaemonTariProvider {
14
15
  this.client = connection;
15
16
  }
16
17
  static async build(params) {
17
- const allPermissions = new TariPermissions();
18
- allPermissions.addPermissions(params.permissions);
19
- allPermissions.addPermissions(params.optionalPermissions);
20
- console.log({ allPermissions });
18
+ const allPermissions = WalletDaemonTariProvider.buildPermissions(params);
21
19
  let connection = new TariConnection(params.signalingServerUrl, params.webRtcConfig);
22
20
  const client = WalletDaemonClient.new(WebRtcRpcTransport.new(connection));
23
21
  await connection.init(allPermissions, (conn) => {
@@ -28,8 +26,29 @@ export class WalletDaemonTariProvider {
28
26
  });
29
27
  return new WalletDaemonTariProvider(params, client);
30
28
  }
29
+ static async buildFetchProvider(params) {
30
+ const allPermissions = WalletDaemonTariProvider.buildPermissions(params);
31
+ const client = WalletDaemonClient.usingFetchTransport(params.serverUrl);
32
+ const plainPermissions = allPermissions.toJSON().flatMap((p) => typeof (p) === "string" ? [p] : []);
33
+ const authResponse = await client.authRequest(plainPermissions);
34
+ await client.authAccept(authResponse, "WalletDaemon");
35
+ params.onConnection?.();
36
+ return new WalletDaemonTariProvider(params, client);
37
+ }
38
+ static buildPermissions(params) {
39
+ const allPermissions = new TariPermissions();
40
+ allPermissions.addPermissions(params.permissions);
41
+ if (params.optionalPermissions) {
42
+ allPermissions.addPermissions(params.optionalPermissions);
43
+ }
44
+ return allPermissions;
45
+ }
46
+ getWebRtcTransport() {
47
+ const transport = this.client.getTransport();
48
+ return transport instanceof WebRtcRpcTransport ? transport : undefined;
49
+ }
31
50
  get token() {
32
- return this.client.getTransport().token();
51
+ return this.getWebRtcTransport()?.token();
33
52
  }
34
53
  get tokenUrl() {
35
54
  if (!this.token) {
@@ -42,7 +61,7 @@ export class WalletDaemonTariProvider {
42
61
  return `tari://${name}/${token}/${permissions}/${optionalPermissions}`;
43
62
  }
44
63
  isConnected() {
45
- return this.client.getTransport().isConnected();
64
+ return this.getWebRtcTransport()?.isConnected() || true;
46
65
  }
47
66
  async createFreeTestCoins() {
48
67
  const res = await this.client.createFreeTestCoins({
@@ -60,17 +79,18 @@ export class WalletDaemonTariProvider {
60
79
  }
61
80
  async getAccount() {
62
81
  const { account, public_key } = await this.client.accountsGetDefault({});
63
- const { balances } = await this.client.accountsGetBalances({ account: { ComponentAddress: account.address.Component }, refresh: false });
82
+ const address = typeof account.address === "object" ? account.address.Component : account.address;
83
+ const { balances } = await this.client.accountsGetBalances({ account: { ComponentAddress: address }, refresh: false });
64
84
  return {
65
85
  account_id: account.key_index,
66
- address: account.address.Component,
86
+ address,
67
87
  public_key,
68
88
  // TODO: should be vaults not resources
69
89
  resources: balances.map((b) => ({
70
90
  type: b.resource_type,
71
91
  resource_address: b.resource_address,
72
92
  balance: b.balance + b.confidential_balance,
73
- vault_id: ('Vault' in b.vault_address) ? b.vault_address.Vault : b.vault_address,
93
+ vault_id: (typeof (b.vault_address) === "object" && 'Vault' in b.vault_address) ? b.vault_address.Vault : b.vault_address,
74
94
  token_symbol: b.token_symbol,
75
95
  }))
76
96
  };
@@ -78,8 +98,8 @@ export class WalletDaemonTariProvider {
78
98
  async getAccountBalances(componentAddress) {
79
99
  return await this.client.accountsGetBalances({ account: { ComponentAddress: componentAddress }, refresh: true });
80
100
  }
81
- async getSubstate(substate_id) {
82
- const substateId = stringToSubstateId(substate_id);
101
+ async getSubstate(substateId) {
102
+ // Wallet daemon expects a SubstateId as a string
83
103
  const { value, record } = await this.client.substatesGet({ substate_id: substateId });
84
104
  return {
85
105
  value,
@@ -92,20 +112,25 @@ export class WalletDaemonTariProvider {
92
112
  async submitTransaction(req) {
93
113
  const params = {
94
114
  transaction: {
95
- instructions: req.instructions,
96
- fee_instructions: req.fee_instructions,
97
- inputs: req.required_substates.map((s) => ({
98
- // TODO: Hmm The bindings want a SubstateId object, but the wallet only wants a string. Any is used to skip type checking here
99
- substate_id: s.substate_id,
100
- version: s.version
101
- })),
102
- min_epoch: null,
103
- max_epoch: null,
115
+ V1: {
116
+ network: req.network,
117
+ instructions: req.instructions,
118
+ fee_instructions: req.fee_instructions,
119
+ inputs: req.required_substates.map((s) => ({
120
+ // TODO: Hmm The bindings want a SubstateId object, but the wallet only wants a string. Any is used to skip type checking here
121
+ substate_id: s.substate_id,
122
+ version: s.version ?? null,
123
+ })),
124
+ min_epoch: null,
125
+ max_epoch: null,
126
+ is_seal_signer_authorized: req.is_seal_signer_authorized,
127
+ },
104
128
  },
105
129
  signing_key_index: req.account_id,
106
130
  autofill_inputs: [],
107
131
  detect_inputs: true,
108
132
  proof_ids: [],
133
+ detect_inputs_use_unversioned: req.detect_inputs_use_unversioned,
109
134
  };
110
135
  const res = await this.client.submitTransaction(params);
111
136
  return { transaction_id: res.transaction_id };
@@ -143,10 +168,10 @@ export class WalletDaemonTariProvider {
143
168
  offset
144
169
  });
145
170
  const substates = resp.substates.map((s) => ({
146
- substate_id: substateIdToString(s.substate_id),
171
+ substate_id: typeof s.substate_id === "string" ? s.substate_id : substateIdToString(s.substate_id),
147
172
  module_name: s.module_name,
148
173
  version: s.version,
149
- template_address: s.template_address
174
+ template_address: s.template_address,
150
175
  }));
151
176
  return { substates };
152
177
  }
@@ -1,7 +1,7 @@
1
1
  import { TransactionStatus, } from "../types";
2
2
  import UniversalProvider from '@walletconnect/universal-provider';
3
3
  import { WalletConnectModal } from '@walletconnect/modal';
4
- import { stringToSubstateId, substateIdToString } from "@tari-project/wallet_jrpc_client";
4
+ import { substateIdToString } from "@tari-project/wallet_jrpc_client";
5
5
  const walletConnectParams = {
6
6
  requiredNamespaces: {
7
7
  tari: {
@@ -83,31 +83,30 @@ export class WalletConnectTariProvider {
83
83
  }
84
84
  async getAccount() {
85
85
  const { account, public_key } = await this.sendRequest('tari_getDefaultAccount', {});
86
- const { balances } = await this.sendRequest('tari_getAccountBalances', { account: { ComponentAddress: account.address.Component }, refresh: false
86
+ const { balances } = await this.sendRequest('tari_getAccountBalances', { account: { ComponentAddress: account.address }, refresh: false
87
87
  });
88
88
  return {
89
89
  account_id: account.key_index,
90
- address: account.address.Component,
90
+ address: account.address,
91
91
  public_key,
92
92
  // TODO: should be vaults not resources
93
93
  resources: balances.map((b) => ({
94
94
  type: b.resource_type,
95
95
  resource_address: b.resource_address,
96
96
  balance: b.balance + b.confidential_balance,
97
- vault_id: ('Vault' in b.vault_address) ? b.vault_address.Vault : b.vault_address,
97
+ vault_id: (typeof (b.vault_address) === "object" && 'Vault' in b.vault_address) ? b.vault_address.Vault : b.vault_address,
98
98
  token_symbol: b.token_symbol,
99
99
  }))
100
100
  };
101
101
  }
102
102
  async getSubstate(substate_address) {
103
- const substateId = stringToSubstateId(substate_address);
104
103
  const method = 'tari_getSubstate';
105
- const params = { substate_id: substateId };
104
+ const params = { substate_id: substate_address };
106
105
  const { value, record } = await this.sendRequest(method, params);
107
106
  return {
108
107
  value,
109
108
  address: {
110
- substate_id: substateIdToString(record.substate_id),
109
+ substate_id: record.substate_id,
111
110
  version: record.version
112
111
  }
113
112
  };
@@ -149,20 +148,25 @@ export class WalletConnectTariProvider {
149
148
  const method = 'tari_submitTransaction';
150
149
  const params = {
151
150
  transaction: {
152
- fee_instructions: req.fee_instructions,
153
- instructions: req.instructions,
154
- inputs: req.required_substates.map((s) => ({
155
- // TODO: Hmm The bindings want a SubstateId object, but the wallet only wants a string. Any is used to skip type checking here
156
- substate_id: s.substate_id,
157
- version: s.version
158
- })),
159
- min_epoch: null,
160
- max_epoch: null,
151
+ V1: {
152
+ network: req.network,
153
+ fee_instructions: req.fee_instructions,
154
+ instructions: req.instructions,
155
+ inputs: req.required_substates.map((s) => ({
156
+ // TODO: Hmm The bindings want a SubstateId object, but the wallet only wants a string. Any is used to skip type checking here
157
+ substate_id: s.substate_id,
158
+ version: s.version ?? null,
159
+ })),
160
+ min_epoch: null,
161
+ max_epoch: null,
162
+ is_seal_signer_authorized: req.is_seal_signer_authorized,
163
+ },
161
164
  },
162
165
  signing_key_index: req.account_id,
163
166
  autofill_inputs: [],
164
167
  detect_inputs: true,
165
168
  proof_ids: [],
169
+ detect_inputs_use_unversioned: req.detect_inputs_use_unversioned,
166
170
  };
167
171
  const res = await this.sendRequest(method, params);
168
172
  return { transaction_id: res.transaction_id };
package/package.json CHANGED
@@ -1,27 +1,29 @@
1
1
  {
2
2
  "name": "@tari-project/tarijs",
3
- "version": "0.2.0",
3
+ "version": "0.3.1",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "publishConfig": {
7
7
  "access": "public"
8
8
  },
9
9
  "scripts": {
10
- "build": "tsc -b"
10
+ "build": "tsc -b",
11
+ "integration-tests": "vitest run integration-tests"
11
12
  },
12
13
  "keywords": [],
13
14
  "author": "",
14
15
  "license": "ISC",
15
16
  "dependencies": {
16
- "@metamask/providers": "^9.0.0",
17
- "@tari-project/wallet_jrpc_client": "^1.1.0",
18
- "@tari-project/typescript-bindings": "^1.1.0",
17
+ "@metamask/providers": "^18.2.0",
18
+ "@tari-project/typescript-bindings": "^1.4.0",
19
+ "@tari-project/wallet_jrpc_client": "^1.4.0",
19
20
  "@walletconnect/modal": "^2.6.2",
20
21
  "@walletconnect/universal-provider": "^2.13.3"
21
22
  },
22
23
  "devDependencies": {
23
24
  "@types/node": "^20.12.6",
24
- "typescript": "^5.0.4"
25
+ "typescript": "^5.0.4",
26
+ "vitest": "^3.0.4"
25
27
  },
26
28
  "files": [
27
29
  "/dist"