@tari-project/tarijs 0.5.0 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Dockerfile +52 -0
- package/README.md +37 -2
- package/TODO.md +0 -4
- package/docusaurus/tari-docs/docs/providers/indexer-provider.md +3 -3
- package/docusaurus/tari-docs/package.json +1 -1
- package/package.json +1 -1
- package/packages/builders/package.json +2 -3
- package/packages/builders/src/helpers/submitTransaction.ts +5 -5
- package/packages/builders/src/transaction/TransactionBuilder.ts +6 -7
- package/packages/builders/src/transaction/TransactionRequest.ts +10 -20
- package/packages/indexer_provider/package.json +1 -1
- package/packages/indexer_provider/src/provider.ts +10 -10
- package/packages/metamask_signer/package.json +1 -1
- package/packages/metamask_signer/src/index.ts +34 -27
- package/packages/tari_permissions/package.json +1 -1
- package/packages/tari_provider/package.json +3 -2
- package/packages/tari_provider/src/TariProvider.ts +5 -5
- package/packages/tari_provider/src/index.ts +0 -1
- package/packages/tari_provider/tsconfig.json +9 -2
- package/packages/tari_signer/package.json +1 -1
- package/packages/tari_signer/src/TariSigner.ts +13 -18
- package/packages/tari_signer/src/index.ts +0 -1
- package/packages/tari_universe/package.json +1 -1
- package/packages/tari_universe/src/signer.ts +23 -28
- package/packages/tari_universe/src/types.ts +0 -5
- package/packages/tarijs/package.json +1 -1
- package/packages/tarijs/src/index.ts +12 -14
- package/packages/tarijs_types/package.json +1 -1
- package/packages/tarijs_types/src/ConfidentialOutput.ts +1 -1
- package/packages/tarijs_types/src/ConfidentialWithdrawProof.ts +1 -1
- package/packages/tarijs_types/src/GetTransactionResultResponse.ts +8 -0
- package/packages/tarijs_types/src/Instruction.ts +8 -5
- package/packages/tarijs_types/src/ListAccountNftFromBalancesRequest.ts +5 -0
- package/packages/tarijs_types/src/Transaction.ts +1 -1
- package/packages/tarijs_types/src/TransactionArg.ts +2 -0
- package/packages/tarijs_types/src/TransactionResult.ts +1 -10
- package/packages/tarijs_types/src/TransactionStatus.ts +9 -0
- package/packages/tarijs_types/src/UnsignedTransaction.ts +1 -2
- package/packages/tarijs_types/src/helpers/index.ts +11 -4
- package/packages/tarijs_types/src/index.ts +28 -10
- package/packages/{tari_provider/src/types.ts → tarijs_types/src/signer.ts} +26 -49
- package/packages/wallet_daemon/package.json +1 -1
- package/packages/wallet_daemon/src/signer.ts +33 -32
- package/packages/walletconnect/package.json +1 -1
- package/packages/walletconnect/src/index.ts +33 -33
- package/packages/tari_signer/src/types.ts +0 -84
- package/packages/tarijs_types/src/Arg.ts +0 -3
- package/packages/tarijs_types/src/ComponentAddress.ts +0 -3
- package/packages/tarijs_types/src/ConfidentialOutputStatement.ts +0 -10
- package/packages/tarijs_types/src/ConfidentialStatement.ts +0 -9
- package/packages/tarijs_types/src/ElgamalVerifiableBalance.ts +0 -4
- package/packages/tarijs_types/src/Epoch.ts +0 -3
- package/packages/tarijs_types/src/ResourceAddress.ts +0 -3
- package/packages/tarijs_types/src/TemplateAddress.ts +0 -3
- package/packages/tarijs_types/src/TransactionId.ts +0 -4
- package/packages/tarijs_types/src/ViewableBalanceProof.ts +0 -12
|
@@ -1,29 +1,24 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SubmitTransactionResponse,
|
|
3
|
-
|
|
3
|
+
AccountData,
|
|
4
4
|
Substate,
|
|
5
5
|
TemplateDefinition,
|
|
6
6
|
VaultBalances,
|
|
7
7
|
ListSubstatesResponse,
|
|
8
8
|
SubmitTransactionRequest,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
} from "@tari-project/tari-signer";
|
|
12
|
-
import {
|
|
13
|
-
SignerRequest,
|
|
14
|
-
SignerMethodNames,
|
|
15
|
-
SignerReturnType,
|
|
16
|
-
TariUniverseSignerParameters,
|
|
17
|
-
WindowSize,
|
|
9
|
+
ListSubstatesRequest,
|
|
10
|
+
GetTransactionResultResponse,
|
|
18
11
|
ListAccountNftFromBalancesRequest,
|
|
19
|
-
} from "
|
|
12
|
+
} from "@tari-project/tarijs-types";
|
|
13
|
+
import { SignerRequest, SignerMethodNames, SignerReturnType, TariUniverseSignerParameters, WindowSize } from "./types";
|
|
20
14
|
import {
|
|
21
15
|
AccountsGetBalancesResponse,
|
|
16
|
+
ConfidentialViewVaultBalanceRequest,
|
|
22
17
|
ListAccountNftRequest,
|
|
23
18
|
ListAccountNftResponse,
|
|
24
|
-
SubstateType,
|
|
25
19
|
} from "@tari-project/wallet_jrpc_client";
|
|
26
20
|
import { sendSignerCall } from "./utils";
|
|
21
|
+
import { TariSigner } from "@tari-project/tari-signer";
|
|
27
22
|
|
|
28
23
|
export class TariUniverseSigner implements TariSigner {
|
|
29
24
|
public signerName = "TariUniverse";
|
|
@@ -56,27 +51,27 @@ export class TariUniverseSigner implements TariSigner {
|
|
|
56
51
|
return this.sendRequest<"getPublicKey">({ methodName: "getPublicKey", args: [] });
|
|
57
52
|
}
|
|
58
53
|
|
|
59
|
-
public async listSubstates(
|
|
60
|
-
filter_by_template
|
|
61
|
-
filter_by_type
|
|
62
|
-
limit
|
|
63
|
-
offset
|
|
64
|
-
): Promise<ListSubstatesResponse> {
|
|
54
|
+
public async listSubstates({
|
|
55
|
+
filter_by_template,
|
|
56
|
+
filter_by_type,
|
|
57
|
+
limit,
|
|
58
|
+
offset,
|
|
59
|
+
}: ListSubstatesRequest): Promise<ListSubstatesResponse> {
|
|
65
60
|
return this.sendRequest<"listSubstates">({
|
|
66
61
|
methodName: "listSubstates",
|
|
67
|
-
args: [filter_by_template, filter_by_type, limit, offset],
|
|
62
|
+
args: [{ filter_by_template, filter_by_type, limit, offset }],
|
|
68
63
|
});
|
|
69
64
|
}
|
|
70
65
|
|
|
71
|
-
public getConfidentialVaultBalances(
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
): Promise<VaultBalances> {
|
|
66
|
+
public getConfidentialVaultBalances({
|
|
67
|
+
vault_id,
|
|
68
|
+
maximum_expected_value,
|
|
69
|
+
minimum_expected_value,
|
|
70
|
+
view_key_id,
|
|
71
|
+
}: ConfidentialViewVaultBalanceRequest): Promise<VaultBalances> {
|
|
77
72
|
return this.sendRequest({
|
|
78
73
|
methodName: "getConfidentialVaultBalances",
|
|
79
|
-
args: [
|
|
74
|
+
args: [{ view_key_id, vault_id, minimum_expected_value, maximum_expected_value }],
|
|
80
75
|
});
|
|
81
76
|
}
|
|
82
77
|
|
|
@@ -88,7 +83,7 @@ export class TariUniverseSigner implements TariSigner {
|
|
|
88
83
|
return this.sendRequest({ methodName: "requestParentSize", args: [] });
|
|
89
84
|
}
|
|
90
85
|
|
|
91
|
-
public async getAccount(): Promise<
|
|
86
|
+
public async getAccount(): Promise<AccountData> {
|
|
92
87
|
return this.sendRequest({ methodName: "getAccount", args: [] });
|
|
93
88
|
}
|
|
94
89
|
|
|
@@ -113,7 +108,7 @@ export class TariUniverseSigner implements TariSigner {
|
|
|
113
108
|
});
|
|
114
109
|
}
|
|
115
110
|
|
|
116
|
-
public async getTransactionResult(transactionId: string): Promise<
|
|
111
|
+
public async getTransactionResult(transactionId: string): Promise<GetTransactionResultResponse> {
|
|
117
112
|
return this.sendRequest({
|
|
118
113
|
methodName: "getTransactionResult",
|
|
119
114
|
args: [transactionId],
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { TariPermissions } from "@tari-project/tari-permissions";
|
|
2
2
|
import { TariUniverseSigner } from "./signer";
|
|
3
|
-
import { BalanceEntry } from "@tari-project/typescript-bindings";
|
|
4
3
|
|
|
5
4
|
export type TariUniverseSignerParameters = {
|
|
6
5
|
permissions: TariPermissions;
|
|
@@ -32,7 +31,3 @@ export type SignerResponse<T extends SignerMethodNames> = {
|
|
|
32
31
|
result: SignerReturnType<T>;
|
|
33
32
|
resultError?: string;
|
|
34
33
|
};
|
|
35
|
-
|
|
36
|
-
export interface ListAccountNftFromBalancesRequest {
|
|
37
|
-
balances: Array<BalanceEntry>;
|
|
38
|
-
}
|
|
@@ -2,18 +2,6 @@ import { TariSigner } from "@tari-project/tari-signer";
|
|
|
2
2
|
import { TariProvider } from "@tari-project/tari-provider";
|
|
3
3
|
import * as utils from "./utils";
|
|
4
4
|
import { Network } from "./network";
|
|
5
|
-
import {
|
|
6
|
-
Account,
|
|
7
|
-
TransactionStatus,
|
|
8
|
-
TransactionResult,
|
|
9
|
-
SubmitTransactionResponse,
|
|
10
|
-
SubmitTransactionRequest,
|
|
11
|
-
VaultBalances,
|
|
12
|
-
VaultData,
|
|
13
|
-
TemplateDefinition,
|
|
14
|
-
SubstateRequirement,
|
|
15
|
-
Substate,
|
|
16
|
-
} from "@tari-project/tari-signer";
|
|
17
5
|
import { MetamaskTariSigner } from "@tari-project/metamask-signer";
|
|
18
6
|
import { MetaMaskInpageProvider } from "@metamask/providers";
|
|
19
7
|
import { WalletDaemonTariSigner, WalletDaemonParameters, TariPermissions } from "@tari-project/wallet-daemon-signer";
|
|
@@ -38,6 +26,16 @@ import {
|
|
|
38
26
|
convertU256ToHexString,
|
|
39
27
|
createNftAddressFromResource,
|
|
40
28
|
createNftAddressFromToken,
|
|
29
|
+
TransactionStatus,
|
|
30
|
+
GetTransactionResultResponse,
|
|
31
|
+
AccountData,
|
|
32
|
+
SubmitTransactionResponse,
|
|
33
|
+
SubmitTransactionRequest,
|
|
34
|
+
VaultBalances,
|
|
35
|
+
VaultData,
|
|
36
|
+
TemplateDefinition,
|
|
37
|
+
SubstateRequirement,
|
|
38
|
+
Substate,
|
|
41
39
|
} from "@tari-project/tarijs-types";
|
|
42
40
|
|
|
43
41
|
export * from "@tari-project/tarijs-types";
|
|
@@ -46,9 +44,9 @@ export {
|
|
|
46
44
|
Network,
|
|
47
45
|
TariSigner,
|
|
48
46
|
TariProvider,
|
|
49
|
-
|
|
47
|
+
AccountData,
|
|
50
48
|
TransactionStatus,
|
|
51
|
-
|
|
49
|
+
GetTransactionResultResponse,
|
|
52
50
|
SubmitTransactionResponse,
|
|
53
51
|
SubmitTransactionRequest,
|
|
54
52
|
VaultBalances,
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { FinalizeResult } from "@tari-project/typescript-bindings";
|
|
2
|
+
import { TransactionStatus } from "./TransactionStatus";
|
|
3
|
+
|
|
4
|
+
export type GetTransactionResultResponse = {
|
|
5
|
+
transaction_id: string;
|
|
6
|
+
status: TransactionStatus;
|
|
7
|
+
result: FinalizeResult | null;
|
|
8
|
+
};
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { ComponentAddress, LogLevel } from "@tari-project/typescript-bindings";
|
|
2
|
-
import {
|
|
1
|
+
import { ComponentAddress, LogLevel, PublishedTemplateAddress } from "@tari-project/typescript-bindings";
|
|
2
|
+
import { TransactionArg } from "./TransactionArg";
|
|
3
3
|
import { ConfidentialClaim } from "./ConfidentialClaim";
|
|
4
4
|
import { Amount } from "./Amount";
|
|
5
5
|
import { ConfidentialOutput } from "./ConfidentialOutput";
|
|
6
|
-
import { TemplateAddress } from "./TemplateAddress";
|
|
7
6
|
|
|
8
7
|
export type Instruction =
|
|
9
8
|
| CreateAccount
|
|
@@ -17,8 +16,12 @@ export type Instruction =
|
|
|
17
16
|
| CreateFreeTestCoins;
|
|
18
17
|
|
|
19
18
|
export type CreateAccount = { CreateAccount: { owner_public_key: string; workspace_bucket: string | null } };
|
|
20
|
-
export type CallFunction = {
|
|
21
|
-
|
|
19
|
+
export type CallFunction = {
|
|
20
|
+
CallFunction: { template_address: PublishedTemplateAddress; function: string; args: Array<TransactionArg> };
|
|
21
|
+
};
|
|
22
|
+
export type CallMethod = {
|
|
23
|
+
CallMethod: { component_address: ComponentAddress; method: string; args: Array<TransactionArg> };
|
|
24
|
+
};
|
|
22
25
|
export type PutLastInstructionOutputOnWorkspace = { PutLastInstructionOutputOnWorkspace: { key: number[] } };
|
|
23
26
|
export type EmitLog = { EmitLog: { level: LogLevel; message: string } };
|
|
24
27
|
export type ClaimBurn = { ClaimBurn: { claim: ConfidentialClaim } };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Instruction } from "./Instruction";
|
|
2
2
|
import { SubstateRequirement } from "./SubstateRequirement";
|
|
3
|
-
import { Epoch } from "./Epoch";
|
|
4
3
|
import { VersionedSubstateId } from "./VersionedSubstateId";
|
|
5
4
|
import { TransactionSignature } from "./TransactionSignature";
|
|
5
|
+
import { Epoch } from "@tari-project/typescript-bindings";
|
|
6
6
|
|
|
7
7
|
export interface Transaction {
|
|
8
8
|
id: string;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { TransactionStatus } from "./TransactionStatus";
|
|
1
2
|
import { FinalizeResult } from "./FinalizeResult";
|
|
2
3
|
|
|
3
4
|
export type SubmitTransactionResponse = {
|
|
@@ -9,16 +10,6 @@ export interface SubmitTxResult {
|
|
|
9
10
|
result: TransactionResult;
|
|
10
11
|
}
|
|
11
12
|
|
|
12
|
-
export enum TransactionStatus {
|
|
13
|
-
New,
|
|
14
|
-
DryRun,
|
|
15
|
-
Pending,
|
|
16
|
-
Accepted,
|
|
17
|
-
Rejected,
|
|
18
|
-
InvalidTransaction,
|
|
19
|
-
OnlyFeeAccepted,
|
|
20
|
-
}
|
|
21
|
-
|
|
22
13
|
export type TransactionResult = {
|
|
23
14
|
transaction_id: string;
|
|
24
15
|
status: TransactionStatus;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
+
import { Epoch } from "@tari-project/typescript-bindings";
|
|
1
2
|
import { Instruction } from "./Instruction";
|
|
2
|
-
import { Epoch } from "./Epoch";
|
|
3
3
|
import { SubstateRequirement } from "./SubstateRequirement";
|
|
4
4
|
import { VersionedSubstateId } from "./VersionedSubstateId";
|
|
5
5
|
|
|
6
|
-
//TODO refactor type (https://github.com/tari-project/tari.js/issues/29)
|
|
7
6
|
// differs from bindings implementation because of 'Instruction'
|
|
8
7
|
export interface UnsignedTransaction {
|
|
9
8
|
feeInstructions: Instruction[];
|
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
import { NonFungibleId, NonFungibleToken, ResourceAddress } from "@tari-project/typescript-bindings";
|
|
2
|
-
import { TransactionStatus } from "../
|
|
2
|
+
import { TransactionStatus } from "../TransactionStatus";
|
|
3
|
+
export {
|
|
4
|
+
substateIdToString,
|
|
5
|
+
stringToSubstateId,
|
|
6
|
+
shortenSubstateId,
|
|
7
|
+
shortenString,
|
|
8
|
+
rejectReasonToString,
|
|
9
|
+
getSubstateDiffFromTransactionResult,
|
|
10
|
+
getRejectReasonFromTransactionResult,
|
|
11
|
+
jrpcPermissionToString,
|
|
12
|
+
} from "@tari-project/typescript-bindings";
|
|
3
13
|
|
|
4
14
|
export function convertStringToTransactionStatus(status: string): TransactionStatus {
|
|
5
15
|
switch (status) {
|
|
@@ -49,12 +59,9 @@ export function convertHexStringToU256Array(hexString: string): number[] {
|
|
|
49
59
|
|
|
50
60
|
export function createNftAddressFromResource(address: ResourceAddress, tokenId: NonFungibleId): string {
|
|
51
61
|
let nftAddress = "nft_";
|
|
52
|
-
|
|
53
62
|
const resourceAddress = address.replace(/^resource_/, "");
|
|
54
63
|
nftAddress += resourceAddress;
|
|
55
|
-
|
|
56
64
|
nftAddress += "_uuid_";
|
|
57
|
-
|
|
58
65
|
const nftIdHexString = convertU256ToHexString(tokenId);
|
|
59
66
|
nftAddress += nftIdHexString;
|
|
60
67
|
|
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { ComponentAddress, ResourceAddress, PublishedTemplateAddress, Epoch } from "@tari-project/typescript-bindings";
|
|
2
2
|
export { Amount } from "./Amount";
|
|
3
|
-
export {
|
|
4
|
-
export { ComponentAddress } from "./ComponentAddress";
|
|
3
|
+
export { TransactionArg } from "./TransactionArg";
|
|
5
4
|
export { ConfidentialClaim } from "./ConfidentialClaim";
|
|
6
5
|
export { ConfidentialOutput } from "./ConfidentialOutput";
|
|
7
|
-
export { ConfidentialOutputStatement } from "./ConfidentialOutputStatement";
|
|
8
|
-
export { ConfidentialStatement } from "./ConfidentialStatement";
|
|
9
6
|
export { ConfidentialWithdrawProof } from "./ConfidentialWithdrawProof";
|
|
10
|
-
export { Epoch } from "./Epoch";
|
|
11
7
|
export {
|
|
12
8
|
FinalizeResult,
|
|
13
9
|
FinalizeResultStatus,
|
|
@@ -15,22 +11,44 @@ export {
|
|
|
15
11
|
TxResultAcceptFeeRejectRest,
|
|
16
12
|
TxResultReject,
|
|
17
13
|
} from "./FinalizeResult";
|
|
18
|
-
export {
|
|
14
|
+
export { GetTransactionResultResponse } from "./GetTransactionResultResponse";
|
|
19
15
|
export { Instruction } from "./Instruction";
|
|
20
16
|
export { Transaction } from "./Transaction";
|
|
21
17
|
export { SubstateDiff, DownSubstates, UpSubstates } from "./SubstateDiff";
|
|
22
18
|
export { SubstateRequirement } from "./SubstateRequirement";
|
|
23
|
-
export {
|
|
24
|
-
export { TransactionResult, TransactionStatus, SubmitTxResult, SubmitTransactionResponse } from "./TransactionResult";
|
|
19
|
+
export { TransactionResult, SubmitTxResult, SubmitTransactionResponse } from "./TransactionResult";
|
|
25
20
|
export { TransactionSignature } from "./TransactionSignature";
|
|
21
|
+
export { TransactionStatus } from "./TransactionStatus";
|
|
26
22
|
export { UnsignedTransaction } from "./UnsignedTransaction";
|
|
27
23
|
export { VersionedSubstateId } from "./VersionedSubstateId";
|
|
28
|
-
export { ViewableBalanceProof } from "./ViewableBalanceProof";
|
|
29
24
|
export { WorkspaceArg } from "./Workspace";
|
|
25
|
+
export { ListAccountNftFromBalancesRequest } from "./ListAccountNftFromBalancesRequest";
|
|
26
|
+
export {
|
|
27
|
+
AccountData,
|
|
28
|
+
ListSubstatesRequest,
|
|
29
|
+
ListSubstatesResponse,
|
|
30
|
+
SubmitTransactionRequest,
|
|
31
|
+
Substate,
|
|
32
|
+
SubstateMetadata,
|
|
33
|
+
ReqSubstate,
|
|
34
|
+
TemplateDefinition,
|
|
35
|
+
VaultBalances,
|
|
36
|
+
VaultData,
|
|
37
|
+
GetSubstateRequest,
|
|
38
|
+
} from "./signer";
|
|
39
|
+
|
|
30
40
|
export {
|
|
31
41
|
convertHexStringToU256Array,
|
|
32
42
|
convertStringToTransactionStatus,
|
|
33
43
|
convertU256ToHexString,
|
|
34
44
|
createNftAddressFromResource,
|
|
35
45
|
createNftAddressFromToken,
|
|
46
|
+
getRejectReasonFromTransactionResult,
|
|
47
|
+
getSubstateDiffFromTransactionResult,
|
|
48
|
+
jrpcPermissionToString,
|
|
49
|
+
rejectReasonToString,
|
|
50
|
+
shortenString,
|
|
51
|
+
shortenSubstateId,
|
|
52
|
+
stringToSubstateId,
|
|
53
|
+
substateIdToString,
|
|
36
54
|
} from "./helpers";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SubstateType, TemplateDef } from "@tari-project/typescript-bindings";
|
|
2
2
|
|
|
3
3
|
export type SubstateMetadata = {
|
|
4
4
|
substate_id: string;
|
|
@@ -7,28 +7,27 @@ export type SubstateMetadata = {
|
|
|
7
7
|
template_address: string | null;
|
|
8
8
|
};
|
|
9
9
|
|
|
10
|
-
export type
|
|
10
|
+
export type ReqSubstate = {
|
|
11
11
|
substate_id: string;
|
|
12
12
|
version?: number | null;
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
-
export type
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
export type SubmitTransactionRequest = {
|
|
16
|
+
network: number;
|
|
17
|
+
account_id: number;
|
|
18
|
+
instructions: object[];
|
|
19
|
+
fee_instructions: object[];
|
|
20
|
+
inputs: object[];
|
|
21
|
+
input_refs: object[];
|
|
22
|
+
required_substates: ReqSubstate[];
|
|
23
|
+
is_dry_run: boolean;
|
|
24
|
+
min_epoch: number | null;
|
|
25
|
+
max_epoch: number | null;
|
|
26
|
+
is_seal_signer_authorized: boolean;
|
|
27
|
+
detect_inputs_use_unversioned: boolean;
|
|
19
28
|
};
|
|
20
29
|
|
|
21
|
-
export
|
|
22
|
-
New,
|
|
23
|
-
DryRun,
|
|
24
|
-
Pending,
|
|
25
|
-
Accepted,
|
|
26
|
-
Rejected,
|
|
27
|
-
InvalidTransaction,
|
|
28
|
-
OnlyFeeAccepted,
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export interface Account {
|
|
30
|
+
export interface AccountData {
|
|
32
31
|
account_id: number;
|
|
33
32
|
address: string;
|
|
34
33
|
public_key: string;
|
|
@@ -47,28 +46,18 @@ export interface VaultBalances {
|
|
|
47
46
|
balances: Map<string, number | null>;
|
|
48
47
|
}
|
|
49
48
|
|
|
50
|
-
export
|
|
51
|
-
// TODO: Define this type
|
|
52
|
-
[key: string]: any;
|
|
53
|
-
}
|
|
49
|
+
export type TemplateDefinition = TemplateDef;
|
|
54
50
|
|
|
55
|
-
export
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
required_substates: SubstateRequirement[];
|
|
63
|
-
is_dry_run: boolean;
|
|
64
|
-
min_epoch: number | null;
|
|
65
|
-
max_epoch: number | null;
|
|
66
|
-
is_seal_signer_authorized: boolean;
|
|
67
|
-
detect_inputs_use_unversioned: boolean;
|
|
68
|
-
};
|
|
51
|
+
export interface Substate {
|
|
52
|
+
value: any;
|
|
53
|
+
address: {
|
|
54
|
+
substate_id: string;
|
|
55
|
+
version: number;
|
|
56
|
+
};
|
|
57
|
+
}
|
|
69
58
|
|
|
70
|
-
export type
|
|
71
|
-
|
|
59
|
+
export type ListSubstatesResponse = {
|
|
60
|
+
substates: Array<SubstateMetadata>;
|
|
72
61
|
};
|
|
73
62
|
|
|
74
63
|
export type ListSubstatesRequest = {
|
|
@@ -78,19 +67,7 @@ export type ListSubstatesRequest = {
|
|
|
78
67
|
offset: number | null;
|
|
79
68
|
};
|
|
80
69
|
|
|
81
|
-
export type ListSubstatesResponse = {
|
|
82
|
-
substates: Array<SubstateMetadata>;
|
|
83
|
-
};
|
|
84
|
-
|
|
85
70
|
export type GetSubstateRequest = {
|
|
86
71
|
substate_address: string;
|
|
87
72
|
version: number | null;
|
|
88
73
|
};
|
|
89
|
-
|
|
90
|
-
export interface Substate {
|
|
91
|
-
value: any;
|
|
92
|
-
address: {
|
|
93
|
-
substate_id: string;
|
|
94
|
-
version: number;
|
|
95
|
-
};
|
|
96
|
-
}
|
|
@@ -1,29 +1,30 @@
|
|
|
1
1
|
import { TariPermissions } from "@tari-project/tari-permissions";
|
|
2
2
|
import { TariConnection } from "./webrtc";
|
|
3
|
-
import {
|
|
4
|
-
SubmitTransactionRequest,
|
|
5
|
-
TransactionResult,
|
|
6
|
-
SubmitTransactionResponse,
|
|
7
|
-
VaultBalances,
|
|
8
|
-
TemplateDefinition,
|
|
9
|
-
Substate,
|
|
10
|
-
ListSubstatesResponse,
|
|
11
|
-
TariSigner,
|
|
12
|
-
} from "@tari-project/tari-signer";
|
|
13
|
-
import { Account } from "@tari-project/tari-signer";
|
|
3
|
+
import { TariSigner } from "@tari-project/tari-signer";
|
|
14
4
|
import {
|
|
15
5
|
WalletDaemonClient,
|
|
16
6
|
substateIdToString,
|
|
17
7
|
Instruction,
|
|
18
|
-
SubstateType,
|
|
19
8
|
SubstatesListRequest,
|
|
20
9
|
KeyBranch,
|
|
21
10
|
SubstateId,
|
|
22
11
|
ListAccountNftRequest,
|
|
23
12
|
ListAccountNftResponse,
|
|
13
|
+
ConfidentialViewVaultBalanceRequest,
|
|
24
14
|
} from "@tari-project/wallet_jrpc_client";
|
|
25
15
|
import { WebRtcRpcTransport } from "./webrtc_transport";
|
|
26
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
AccountData,
|
|
18
|
+
convertStringToTransactionStatus,
|
|
19
|
+
GetTransactionResultResponse,
|
|
20
|
+
SubmitTransactionRequest,
|
|
21
|
+
SubmitTransactionResponse,
|
|
22
|
+
VaultBalances,
|
|
23
|
+
TemplateDefinition,
|
|
24
|
+
Substate,
|
|
25
|
+
ListSubstatesResponse,
|
|
26
|
+
ListSubstatesRequest,
|
|
27
|
+
} from "@tari-project/tarijs-types";
|
|
27
28
|
|
|
28
29
|
export const WalletDaemonNotConnected = "WALLET_DAEMON_NOT_CONNECTED";
|
|
29
30
|
export const Unsupported = "UNSUPPORTED";
|
|
@@ -114,7 +115,7 @@ export class WalletDaemonTariSigner implements TariSigner {
|
|
|
114
115
|
return this.getWebRtcTransport()?.isConnected() || true;
|
|
115
116
|
}
|
|
116
117
|
|
|
117
|
-
public async createFreeTestCoins(): Promise<
|
|
118
|
+
public async createFreeTestCoins(): Promise<AccountData> {
|
|
118
119
|
const res = await this.client.createFreeTestCoins({
|
|
119
120
|
account: { Name: "template_web" },
|
|
120
121
|
amount: 1000000,
|
|
@@ -129,7 +130,7 @@ export class WalletDaemonTariSigner implements TariSigner {
|
|
|
129
130
|
};
|
|
130
131
|
}
|
|
131
132
|
|
|
132
|
-
public async getAccount(): Promise<
|
|
133
|
+
public async getAccount(): Promise<AccountData> {
|
|
133
134
|
const { account, public_key } = (await this.client.accountsGetDefault({})) as any;
|
|
134
135
|
const address = typeof account.address === "object" ? account.address.Component : account.address;
|
|
135
136
|
const { balances } = await this.client.accountsGetBalances({
|
|
@@ -197,7 +198,7 @@ export class WalletDaemonTariSigner implements TariSigner {
|
|
|
197
198
|
return { transaction_id: res.transaction_id };
|
|
198
199
|
}
|
|
199
200
|
|
|
200
|
-
public async getTransactionResult(transactionId: string): Promise<
|
|
201
|
+
public async getTransactionResult(transactionId: string): Promise<GetTransactionResultResponse> {
|
|
201
202
|
const res = await this.client.getTransactionResult({ transaction_id: transactionId });
|
|
202
203
|
|
|
203
204
|
return {
|
|
@@ -217,27 +218,27 @@ export class WalletDaemonTariSigner implements TariSigner {
|
|
|
217
218
|
return resp.template_definition as TemplateDefinition;
|
|
218
219
|
}
|
|
219
220
|
|
|
220
|
-
public async getConfidentialVaultBalances(
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
): Promise<VaultBalances> {
|
|
221
|
+
public async getConfidentialVaultBalances({
|
|
222
|
+
vault_id,
|
|
223
|
+
view_key_id,
|
|
224
|
+
maximum_expected_value = null,
|
|
225
|
+
minimum_expected_value = null,
|
|
226
|
+
}: ConfidentialViewVaultBalanceRequest): Promise<VaultBalances> {
|
|
226
227
|
const res = await this.client.viewVaultBalance({
|
|
227
|
-
view_key_id
|
|
228
|
-
vault_id
|
|
229
|
-
minimum_expected_value
|
|
230
|
-
maximum_expected_value
|
|
228
|
+
view_key_id,
|
|
229
|
+
vault_id,
|
|
230
|
+
minimum_expected_value,
|
|
231
|
+
maximum_expected_value,
|
|
231
232
|
});
|
|
232
233
|
return { balances: res.balances as unknown as Map<string, number | null> };
|
|
233
234
|
}
|
|
234
235
|
|
|
235
|
-
public async listSubstates(
|
|
236
|
-
filter_by_template
|
|
237
|
-
filter_by_type
|
|
238
|
-
limit
|
|
239
|
-
offset
|
|
240
|
-
): Promise<ListSubstatesResponse> {
|
|
236
|
+
public async listSubstates({
|
|
237
|
+
filter_by_template,
|
|
238
|
+
filter_by_type,
|
|
239
|
+
limit,
|
|
240
|
+
offset,
|
|
241
|
+
}: ListSubstatesRequest): Promise<ListSubstatesResponse> {
|
|
241
242
|
const resp = await this.client.substatesList({
|
|
242
243
|
filter_by_template,
|
|
243
244
|
filter_by_type,
|