@kynesyslabs/demosdk 2.5.3 → 2.5.4
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/build/encryption/Hashing.d.ts +1 -0
- package/build/encryption/Hashing.js +5 -0
- package/build/encryption/Hashing.js.map +1 -1
- package/build/escrow/EscrowQueries.d.ts +112 -0
- package/build/escrow/EscrowQueries.js +97 -0
- package/build/escrow/EscrowQueries.js.map +1 -0
- package/build/escrow/EscrowTransaction.d.ts +89 -0
- package/build/escrow/EscrowTransaction.js +304 -0
- package/build/escrow/EscrowTransaction.js.map +1 -0
- package/build/escrow/index.d.ts +3 -0
- package/build/escrow/index.js +18 -0
- package/build/escrow/index.js.map +1 -0
- package/build/index.d.ts +1 -0
- package/build/index.js +2 -1
- package/build/index.js.map +1 -1
- package/build/types/blockchain/GCREdit.d.ts +22 -1
- package/build/types/blockchain/Transaction.d.ts +3 -2
- package/build/types/blockchain/Transaction.js.map +1 -1
- package/build/types/blockchain/TransactionSubtypes/EscrowTransaction.d.ts +14 -0
- package/build/types/blockchain/TransactionSubtypes/EscrowTransaction.js +3 -0
- package/build/types/blockchain/TransactionSubtypes/EscrowTransaction.js.map +1 -0
- package/build/types/blockchain/TransactionSubtypes/index.d.ts +3 -1
- package/build/types/blockchain/TransactionSubtypes/index.js +1 -0
- package/build/types/blockchain/TransactionSubtypes/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -16,12 +16,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
16
16
|
exports.Hashing = void 0;
|
|
17
17
|
const node_forge_1 = __importDefault(require("node-forge"));
|
|
18
18
|
const sha3_1 = require("@noble/hashes/sha3");
|
|
19
|
+
const utils_1 = require("@noble/hashes/utils");
|
|
19
20
|
class Hashing {
|
|
20
21
|
static sha256(message) {
|
|
21
22
|
const md = node_forge_1.default.sha256.create();
|
|
22
23
|
md.update(message);
|
|
23
24
|
return md.digest().toHex();
|
|
24
25
|
}
|
|
26
|
+
static sha3_256(message) {
|
|
27
|
+
const hash = (0, sha3_1.sha3_256)(message);
|
|
28
|
+
return (0, utils_1.bytesToHex)(hash);
|
|
29
|
+
}
|
|
25
30
|
static sha3_512(message) {
|
|
26
31
|
return (0, sha3_1.sha3_512)(message);
|
|
27
32
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Hashing.js","sourceRoot":"","sources":["../../../src/encryption/Hashing.ts"],"names":[],"mappings":";AAAA;;;;;;;;;EASE;;;;;;AAEF,4DAA8B;AAC9B,
|
|
1
|
+
{"version":3,"file":"Hashing.js","sourceRoot":"","sources":["../../../src/encryption/Hashing.ts"],"names":[],"mappings":";AAAA;;;;;;;;;EASE;;;;;;AAEF,4DAA8B;AAC9B,6CAAuD;AACvD,+CAAgD;AAEhD,MAAa,OAAO;IAChB,MAAM,CAAC,MAAM,CAAC,OAAe;QACzB,MAAM,EAAE,GAAG,oBAAK,CAAC,MAAM,CAAC,MAAM,EAAE,CAAA;QAChC,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;QAClB,OAAO,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,CAAA;IAC9B,CAAC;IAED,MAAM,CAAC,QAAQ,CAAC,OAA4B;QACxC,MAAM,IAAI,GAAG,IAAA,eAAQ,EAAC,OAAO,CAAC,CAAA;QAC9B,OAAO,IAAA,kBAAU,EAAC,IAAI,CAAC,CAAA;IAC3B,CAAC;IAED,MAAM,CAAC,QAAQ,CAAC,OAA4B;QACxC,OAAO,IAAA,eAAQ,EAAC,OAAO,CAAC,CAAA;IAC5B,CAAC;CACJ;AAfD,0BAeC"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { Demos } from "../websdk";
|
|
2
|
+
/**
|
|
3
|
+
* Escrow balance information
|
|
4
|
+
*/
|
|
5
|
+
export interface EscrowBalance {
|
|
6
|
+
escrowAddress: string;
|
|
7
|
+
exists: boolean;
|
|
8
|
+
balance: string;
|
|
9
|
+
deposits: Array<{
|
|
10
|
+
from: string;
|
|
11
|
+
amount: string;
|
|
12
|
+
timestamp: number;
|
|
13
|
+
message?: string;
|
|
14
|
+
}>;
|
|
15
|
+
expiryTimestamp: number;
|
|
16
|
+
expired: boolean;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Claimable escrow information
|
|
20
|
+
*/
|
|
21
|
+
export interface ClaimableEscrow {
|
|
22
|
+
platform: "twitter" | "github" | "telegram";
|
|
23
|
+
username: string;
|
|
24
|
+
balance: string;
|
|
25
|
+
escrowAddress: string;
|
|
26
|
+
deposits: Array<{
|
|
27
|
+
from: string;
|
|
28
|
+
amount: string;
|
|
29
|
+
timestamp: number;
|
|
30
|
+
message?: string;
|
|
31
|
+
}>;
|
|
32
|
+
expiryTimestamp: number;
|
|
33
|
+
expired: boolean;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Sent escrow information
|
|
37
|
+
*/
|
|
38
|
+
export interface SentEscrow {
|
|
39
|
+
platform: "twitter" | "github" | "telegram";
|
|
40
|
+
username: string;
|
|
41
|
+
escrowAddress: string;
|
|
42
|
+
totalSent: string;
|
|
43
|
+
deposits: Array<{
|
|
44
|
+
amount: string;
|
|
45
|
+
timestamp: number;
|
|
46
|
+
message?: string;
|
|
47
|
+
}>;
|
|
48
|
+
totalEscrowBalance: string;
|
|
49
|
+
expired: boolean;
|
|
50
|
+
expiryTimestamp: number;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* RPC query helpers for escrow operations
|
|
54
|
+
* Convenience wrappers around RPC endpoints
|
|
55
|
+
*/
|
|
56
|
+
export declare class EscrowQueries {
|
|
57
|
+
/**
|
|
58
|
+
* Query escrow balance for a specific social identity
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```typescript
|
|
62
|
+
* const escrow = await EscrowQueries.getEscrowBalance(
|
|
63
|
+
* demos,
|
|
64
|
+
* "twitter",
|
|
65
|
+
* "@bob"
|
|
66
|
+
* )
|
|
67
|
+
* console.log(`Escrow balance: ${escrow.balance} DEM`)
|
|
68
|
+
* ```
|
|
69
|
+
*
|
|
70
|
+
* @param demos - Demos SDK instance
|
|
71
|
+
* @param platform - Social platform
|
|
72
|
+
* @param username - Username on that platform
|
|
73
|
+
* @returns Escrow balance information
|
|
74
|
+
*/
|
|
75
|
+
static getEscrowBalance(demos: Demos, platform: string, username: string): Promise<EscrowBalance>;
|
|
76
|
+
/**
|
|
77
|
+
* Get all escrows claimable by a Demos address
|
|
78
|
+
* Checks which Web2 identities the address has proven
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* ```typescript
|
|
82
|
+
* const claimable = await EscrowQueries.getClaimableEscrows(
|
|
83
|
+
* demos,
|
|
84
|
+
* myAddress
|
|
85
|
+
* )
|
|
86
|
+
* console.log(`You have ${claimable.length} claimable escrows`)
|
|
87
|
+
* ```
|
|
88
|
+
*
|
|
89
|
+
* @param demos - Demos SDK instance
|
|
90
|
+
* @param address - Demos address to check
|
|
91
|
+
* @returns Array of claimable escrows
|
|
92
|
+
*/
|
|
93
|
+
static getClaimableEscrows(demos: Demos, address: string): Promise<ClaimableEscrow[]>;
|
|
94
|
+
/**
|
|
95
|
+
* Get all escrows sent by a specific address
|
|
96
|
+
* Useful for seeing where you've sent funds
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```typescript
|
|
100
|
+
* const sent = await EscrowQueries.getSentEscrows(
|
|
101
|
+
* demos,
|
|
102
|
+
* myAddress
|
|
103
|
+
* )
|
|
104
|
+
* console.log(`You've sent escrows to ${sent.length} identities`)
|
|
105
|
+
* ```
|
|
106
|
+
*
|
|
107
|
+
* @param demos - Demos SDK instance
|
|
108
|
+
* @param sender - Sender's Demos address
|
|
109
|
+
* @returns Array of sent escrows
|
|
110
|
+
*/
|
|
111
|
+
static getSentEscrows(demos: Demos, sender: string): Promise<SentEscrow[]>;
|
|
112
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* LICENSE
|
|
3
|
+
|
|
4
|
+
© 2023 by KyneSys Labs, licensed under CC BY-NC-ND 4.0
|
|
5
|
+
|
|
6
|
+
Full license text: https://creativecommons.org/licenses/by-nc-nd/4.0/legalcode
|
|
7
|
+
Human readable license: https://creativecommons.org/licenses/by-nc-nd/4.0/
|
|
8
|
+
|
|
9
|
+
KyneSys Labs: https://www.kynesys.xyz/
|
|
10
|
+
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.EscrowQueries = void 0;
|
|
14
|
+
/**
|
|
15
|
+
* RPC query helpers for escrow operations
|
|
16
|
+
* Convenience wrappers around RPC endpoints
|
|
17
|
+
*/
|
|
18
|
+
class EscrowQueries {
|
|
19
|
+
/**
|
|
20
|
+
* Query escrow balance for a specific social identity
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* const escrow = await EscrowQueries.getEscrowBalance(
|
|
25
|
+
* demos,
|
|
26
|
+
* "twitter",
|
|
27
|
+
* "@bob"
|
|
28
|
+
* )
|
|
29
|
+
* console.log(`Escrow balance: ${escrow.balance} DEM`)
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* @param demos - Demos SDK instance
|
|
33
|
+
* @param platform - Social platform
|
|
34
|
+
* @param username - Username on that platform
|
|
35
|
+
* @returns Escrow balance information
|
|
36
|
+
*/
|
|
37
|
+
static async getEscrowBalance(demos, platform, username) {
|
|
38
|
+
const request = {
|
|
39
|
+
method: "get_escrow_balance",
|
|
40
|
+
params: [{ platform, username }],
|
|
41
|
+
};
|
|
42
|
+
const result = await demos.rpcCall(request, false);
|
|
43
|
+
return result.response;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Get all escrows claimable by a Demos address
|
|
47
|
+
* Checks which Web2 identities the address has proven
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```typescript
|
|
51
|
+
* const claimable = await EscrowQueries.getClaimableEscrows(
|
|
52
|
+
* demos,
|
|
53
|
+
* myAddress
|
|
54
|
+
* )
|
|
55
|
+
* console.log(`You have ${claimable.length} claimable escrows`)
|
|
56
|
+
* ```
|
|
57
|
+
*
|
|
58
|
+
* @param demos - Demos SDK instance
|
|
59
|
+
* @param address - Demos address to check
|
|
60
|
+
* @returns Array of claimable escrows
|
|
61
|
+
*/
|
|
62
|
+
static async getClaimableEscrows(demos, address) {
|
|
63
|
+
const request = {
|
|
64
|
+
method: "get_claimable_escrows",
|
|
65
|
+
params: [{ address }],
|
|
66
|
+
};
|
|
67
|
+
const result = await demos.rpcCall(request, false);
|
|
68
|
+
return result.response;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Get all escrows sent by a specific address
|
|
72
|
+
* Useful for seeing where you've sent funds
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```typescript
|
|
76
|
+
* const sent = await EscrowQueries.getSentEscrows(
|
|
77
|
+
* demos,
|
|
78
|
+
* myAddress
|
|
79
|
+
* )
|
|
80
|
+
* console.log(`You've sent escrows to ${sent.length} identities`)
|
|
81
|
+
* ```
|
|
82
|
+
*
|
|
83
|
+
* @param demos - Demos SDK instance
|
|
84
|
+
* @param sender - Sender's Demos address
|
|
85
|
+
* @returns Array of sent escrows
|
|
86
|
+
*/
|
|
87
|
+
static async getSentEscrows(demos, sender) {
|
|
88
|
+
const request = {
|
|
89
|
+
method: "get_sent_escrows",
|
|
90
|
+
params: [{ sender }],
|
|
91
|
+
};
|
|
92
|
+
const result = await demos.rpcCall(request, false);
|
|
93
|
+
return result.response;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
exports.EscrowQueries = EscrowQueries;
|
|
97
|
+
//# sourceMappingURL=EscrowQueries.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EscrowQueries.js","sourceRoot":"","sources":["../../../src/escrow/EscrowQueries.ts"],"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|
|
4
|
+
* High-level API for creating escrow transactions
|
|
5
|
+
* Enables trustless sending of DEM to unclaimed social identities
|
|
6
|
+
*/
|
|
7
|
+
export declare class EscrowTransaction {
|
|
8
|
+
/**
|
|
9
|
+
* Computes deterministic escrow address from platform:username
|
|
10
|
+
* MUST MATCH the node implementation!
|
|
11
|
+
*
|
|
12
|
+
* @param platform - Social platform ("twitter", "github", "telegram")
|
|
13
|
+
* @param username - Username on that platform (e.g., "@bob")
|
|
14
|
+
* @returns Hex-encoded escrow address
|
|
15
|
+
*/
|
|
16
|
+
static getEscrowAddress(platform: string, username: string): string;
|
|
17
|
+
/**
|
|
18
|
+
* Creates a transaction to send DEM to a social identity escrow
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* const tx = await EscrowTransaction.sendToIdentity(
|
|
23
|
+
* demos,
|
|
24
|
+
* "twitter",
|
|
25
|
+
* "@bob",
|
|
26
|
+
* 100,
|
|
27
|
+
* { expiryDays: 30, message: "Welcome to Demos!" }
|
|
28
|
+
* )
|
|
29
|
+
* await demos.submitTransaction(tx)
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* @param demos - Demos SDK instance (must have keypair set)
|
|
33
|
+
* @param platform - Social platform ("twitter", "github", "telegram")
|
|
34
|
+
* @param username - Username on that platform
|
|
35
|
+
* @param amount - Amount of DEM to send (number)
|
|
36
|
+
* @param options - Optional parameters
|
|
37
|
+
* @returns Signed transaction ready to submit
|
|
38
|
+
*/
|
|
39
|
+
static sendToIdentity(demos: Demos, platform: "twitter" | "github" | "telegram", username: string, amount: number, options?: {
|
|
40
|
+
expiryDays?: number;
|
|
41
|
+
message?: string;
|
|
42
|
+
}): Promise<Transaction>;
|
|
43
|
+
/**
|
|
44
|
+
* Creates a transaction to claim escrowed funds
|
|
45
|
+
*
|
|
46
|
+
* Prerequisites:
|
|
47
|
+
* - Claimant must have already proven ownership of the social identity
|
|
48
|
+
* (via Web2 identity linking transaction)
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```typescript
|
|
52
|
+
* // Bob links Twitter first
|
|
53
|
+
* await demos.Web2.linkTwitter("@bob")
|
|
54
|
+
*
|
|
55
|
+
* // Then claims escrow
|
|
56
|
+
* const tx = await EscrowTransaction.claimEscrow(
|
|
57
|
+
* demos,
|
|
58
|
+
* "twitter",
|
|
59
|
+
* "@bob"
|
|
60
|
+
* )
|
|
61
|
+
* await demos.submitTransaction(tx)
|
|
62
|
+
* ```
|
|
63
|
+
*
|
|
64
|
+
* @param demos - Demos SDK instance (must have keypair set)
|
|
65
|
+
* @param platform - Social platform
|
|
66
|
+
* @param username - Username to claim for
|
|
67
|
+
* @returns Signed transaction ready to submit
|
|
68
|
+
*/
|
|
69
|
+
static claimEscrow(demos: Demos, platform: "twitter" | "github" | "telegram", username: string): Promise<Transaction>;
|
|
70
|
+
/**
|
|
71
|
+
* Creates a transaction to refund an expired escrow
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```typescript
|
|
75
|
+
* const tx = await EscrowTransaction.refundExpiredEscrow(
|
|
76
|
+
* demos,
|
|
77
|
+
* "twitter",
|
|
78
|
+
* "@unclaimed_user"
|
|
79
|
+
* )
|
|
80
|
+
* await demos.submitTransaction(tx)
|
|
81
|
+
* ```
|
|
82
|
+
*
|
|
83
|
+
* @param demos - Demos SDK instance (must have keypair set)
|
|
84
|
+
* @param platform - Social platform
|
|
85
|
+
* @param username - Username
|
|
86
|
+
* @returns Signed transaction ready to submit
|
|
87
|
+
*/
|
|
88
|
+
static refundExpiredEscrow(demos: Demos, platform: "twitter" | "github" | "telegram", username: string): Promise<Transaction>;
|
|
89
|
+
}
|
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* LICENSE
|
|
3
|
+
|
|
4
|
+
© 2023 by KyneSys Labs, licensed under CC BY-NC-ND 4.0
|
|
5
|
+
|
|
6
|
+
Full license text: https://creativecommons.org/licenses/by-nc-nd/4.0/legalcode
|
|
7
|
+
Human readable license: https://creativecommons.org/licenses/by-nc-nd/4.0/
|
|
8
|
+
|
|
9
|
+
KyneSys Labs: https://www.kynesys.xyz/
|
|
10
|
+
|
|
11
|
+
*/
|
|
12
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
15
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
16
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
17
|
+
}
|
|
18
|
+
Object.defineProperty(o, k2, desc);
|
|
19
|
+
}) : (function(o, m, k, k2) {
|
|
20
|
+
if (k2 === undefined) k2 = k;
|
|
21
|
+
o[k2] = m[k];
|
|
22
|
+
}));
|
|
23
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
24
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
25
|
+
}) : function(o, v) {
|
|
26
|
+
o["default"] = v;
|
|
27
|
+
});
|
|
28
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
29
|
+
var ownKeys = function(o) {
|
|
30
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
31
|
+
var ar = [];
|
|
32
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
33
|
+
return ar;
|
|
34
|
+
};
|
|
35
|
+
return ownKeys(o);
|
|
36
|
+
};
|
|
37
|
+
return function (mod) {
|
|
38
|
+
if (mod && mod.__esModule) return mod;
|
|
39
|
+
var result = {};
|
|
40
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
41
|
+
__setModuleDefault(result, mod);
|
|
42
|
+
return result;
|
|
43
|
+
};
|
|
44
|
+
})();
|
|
45
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
|
+
exports.EscrowTransaction = void 0;
|
|
47
|
+
const Hashing_1 = require("../encryption/Hashing");
|
|
48
|
+
const unifiedCrypto_1 = require("../encryption/unifiedCrypto");
|
|
49
|
+
const skeletons = __importStar(require("../websdk/utils/skeletons"));
|
|
50
|
+
/**
|
|
51
|
+
* High-level API for creating escrow transactions
|
|
52
|
+
* Enables trustless sending of DEM to unclaimed social identities
|
|
53
|
+
*/
|
|
54
|
+
class EscrowTransaction {
|
|
55
|
+
/**
|
|
56
|
+
* Computes deterministic escrow address from platform:username
|
|
57
|
+
* MUST MATCH the node implementation!
|
|
58
|
+
*
|
|
59
|
+
* @param platform - Social platform ("twitter", "github", "telegram")
|
|
60
|
+
* @param username - Username on that platform (e.g., "@bob")
|
|
61
|
+
* @returns Hex-encoded escrow address
|
|
62
|
+
*/
|
|
63
|
+
static getEscrowAddress(platform, username) {
|
|
64
|
+
// Normalize to lowercase for case-insensitivity
|
|
65
|
+
const identity = `${platform}:${username}`.toLowerCase();
|
|
66
|
+
// Use SHA3-256 for deterministic address generation
|
|
67
|
+
return Hashing_1.Hashing.sha3_256(identity);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Creates a transaction to send DEM to a social identity escrow
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```typescript
|
|
74
|
+
* const tx = await EscrowTransaction.sendToIdentity(
|
|
75
|
+
* demos,
|
|
76
|
+
* "twitter",
|
|
77
|
+
* "@bob",
|
|
78
|
+
* 100,
|
|
79
|
+
* { expiryDays: 30, message: "Welcome to Demos!" }
|
|
80
|
+
* )
|
|
81
|
+
* await demos.submitTransaction(tx)
|
|
82
|
+
* ```
|
|
83
|
+
*
|
|
84
|
+
* @param demos - Demos SDK instance (must have keypair set)
|
|
85
|
+
* @param platform - Social platform ("twitter", "github", "telegram")
|
|
86
|
+
* @param username - Username on that platform
|
|
87
|
+
* @param amount - Amount of DEM to send (number)
|
|
88
|
+
* @param options - Optional parameters
|
|
89
|
+
* @returns Signed transaction ready to submit
|
|
90
|
+
*/
|
|
91
|
+
static async sendToIdentity(demos, platform, username, amount, options) {
|
|
92
|
+
// Get sender address from demos instance
|
|
93
|
+
const { publicKey } = await demos.crypto.getIdentity("ed25519");
|
|
94
|
+
const sender = (0, unifiedCrypto_1.uint8ArrayToHex)(publicKey);
|
|
95
|
+
// Compute escrow address
|
|
96
|
+
const escrowAddress = this.getEscrowAddress(platform, username);
|
|
97
|
+
// Get nonce
|
|
98
|
+
const nonce = await demos.getAddressNonce(sender);
|
|
99
|
+
// Create empty transaction
|
|
100
|
+
let tx = structuredClone(skeletons.transaction);
|
|
101
|
+
// Build GCREdits
|
|
102
|
+
const gcrEdits = [
|
|
103
|
+
// 1. Deduct from sender's balance
|
|
104
|
+
{
|
|
105
|
+
type: "balance",
|
|
106
|
+
operation: "remove",
|
|
107
|
+
account: sender,
|
|
108
|
+
amount: amount,
|
|
109
|
+
txhash: "",
|
|
110
|
+
isRollback: false,
|
|
111
|
+
},
|
|
112
|
+
// 2. Deposit to escrow
|
|
113
|
+
{
|
|
114
|
+
type: "escrow",
|
|
115
|
+
operation: "deposit",
|
|
116
|
+
account: escrowAddress,
|
|
117
|
+
data: {
|
|
118
|
+
sender,
|
|
119
|
+
platform,
|
|
120
|
+
username,
|
|
121
|
+
amount: amount,
|
|
122
|
+
expiryDays: options?.expiryDays || 30,
|
|
123
|
+
message: options?.message,
|
|
124
|
+
},
|
|
125
|
+
txhash: "",
|
|
126
|
+
isRollback: false,
|
|
127
|
+
},
|
|
128
|
+
];
|
|
129
|
+
// Fill transaction content
|
|
130
|
+
tx.content.from = sender;
|
|
131
|
+
tx.content.to = escrowAddress;
|
|
132
|
+
tx.content.nonce = nonce + 1;
|
|
133
|
+
tx.content.amount = amount;
|
|
134
|
+
tx.content.type = "escrow";
|
|
135
|
+
tx.content.timestamp = Date.now();
|
|
136
|
+
tx.content.gcr_edits = gcrEdits;
|
|
137
|
+
tx.content.data = [
|
|
138
|
+
"escrow",
|
|
139
|
+
{
|
|
140
|
+
platform,
|
|
141
|
+
username,
|
|
142
|
+
amount: amount.toString(),
|
|
143
|
+
operation: "deposit",
|
|
144
|
+
},
|
|
145
|
+
];
|
|
146
|
+
// Sign transaction
|
|
147
|
+
return await demos.sign(tx);
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Creates a transaction to claim escrowed funds
|
|
151
|
+
*
|
|
152
|
+
* Prerequisites:
|
|
153
|
+
* - Claimant must have already proven ownership of the social identity
|
|
154
|
+
* (via Web2 identity linking transaction)
|
|
155
|
+
*
|
|
156
|
+
* @example
|
|
157
|
+
* ```typescript
|
|
158
|
+
* // Bob links Twitter first
|
|
159
|
+
* await demos.Web2.linkTwitter("@bob")
|
|
160
|
+
*
|
|
161
|
+
* // Then claims escrow
|
|
162
|
+
* const tx = await EscrowTransaction.claimEscrow(
|
|
163
|
+
* demos,
|
|
164
|
+
* "twitter",
|
|
165
|
+
* "@bob"
|
|
166
|
+
* )
|
|
167
|
+
* await demos.submitTransaction(tx)
|
|
168
|
+
* ```
|
|
169
|
+
*
|
|
170
|
+
* @param demos - Demos SDK instance (must have keypair set)
|
|
171
|
+
* @param platform - Social platform
|
|
172
|
+
* @param username - Username to claim for
|
|
173
|
+
* @returns Signed transaction ready to submit
|
|
174
|
+
*/
|
|
175
|
+
static async claimEscrow(demos, platform, username) {
|
|
176
|
+
// Get claimant address from demos instance
|
|
177
|
+
const { publicKey } = await demos.crypto.getIdentity("ed25519");
|
|
178
|
+
const claimant = (0, unifiedCrypto_1.uint8ArrayToHex)(publicKey);
|
|
179
|
+
// Compute escrow address
|
|
180
|
+
const escrowAddress = this.getEscrowAddress(platform, username);
|
|
181
|
+
// Get nonce
|
|
182
|
+
const nonce = await demos.getAddressNonce(claimant);
|
|
183
|
+
// Create empty transaction
|
|
184
|
+
let tx = structuredClone(skeletons.transaction);
|
|
185
|
+
// Build GCREdits
|
|
186
|
+
const gcrEdits = [
|
|
187
|
+
// 1. Claim escrow (includes identity verification on node side)
|
|
188
|
+
{
|
|
189
|
+
type: "escrow",
|
|
190
|
+
operation: "claim",
|
|
191
|
+
account: escrowAddress,
|
|
192
|
+
data: {
|
|
193
|
+
claimant,
|
|
194
|
+
platform,
|
|
195
|
+
username,
|
|
196
|
+
},
|
|
197
|
+
txhash: "",
|
|
198
|
+
isRollback: false,
|
|
199
|
+
},
|
|
200
|
+
// 2. Add to claimant's balance
|
|
201
|
+
// Note: Amount will be determined during escrow claim validation by consensus
|
|
202
|
+
{
|
|
203
|
+
type: "balance",
|
|
204
|
+
operation: "add",
|
|
205
|
+
account: claimant,
|
|
206
|
+
amount: 0, // Placeholder - filled by node during validation
|
|
207
|
+
txhash: "",
|
|
208
|
+
isRollback: false,
|
|
209
|
+
},
|
|
210
|
+
];
|
|
211
|
+
// Fill transaction content
|
|
212
|
+
tx.content.from = claimant;
|
|
213
|
+
tx.content.to = escrowAddress;
|
|
214
|
+
tx.content.nonce = nonce + 1;
|
|
215
|
+
tx.content.amount = 0; // Amount filled by node
|
|
216
|
+
tx.content.type = "escrow";
|
|
217
|
+
tx.content.timestamp = Date.now();
|
|
218
|
+
tx.content.gcr_edits = gcrEdits;
|
|
219
|
+
tx.content.data = [
|
|
220
|
+
"escrow",
|
|
221
|
+
{
|
|
222
|
+
platform,
|
|
223
|
+
username,
|
|
224
|
+
operation: "claim",
|
|
225
|
+
},
|
|
226
|
+
];
|
|
227
|
+
// Sign transaction
|
|
228
|
+
return await demos.sign(tx);
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Creates a transaction to refund an expired escrow
|
|
232
|
+
*
|
|
233
|
+
* @example
|
|
234
|
+
* ```typescript
|
|
235
|
+
* const tx = await EscrowTransaction.refundExpiredEscrow(
|
|
236
|
+
* demos,
|
|
237
|
+
* "twitter",
|
|
238
|
+
* "@unclaimed_user"
|
|
239
|
+
* )
|
|
240
|
+
* await demos.submitTransaction(tx)
|
|
241
|
+
* ```
|
|
242
|
+
*
|
|
243
|
+
* @param demos - Demos SDK instance (must have keypair set)
|
|
244
|
+
* @param platform - Social platform
|
|
245
|
+
* @param username - Username
|
|
246
|
+
* @returns Signed transaction ready to submit
|
|
247
|
+
*/
|
|
248
|
+
static async refundExpiredEscrow(demos, platform, username) {
|
|
249
|
+
// Get refunder address from demos instance
|
|
250
|
+
const { publicKey } = await demos.crypto.getIdentity("ed25519");
|
|
251
|
+
const refunder = (0, unifiedCrypto_1.uint8ArrayToHex)(publicKey);
|
|
252
|
+
// Compute escrow address
|
|
253
|
+
const escrowAddress = this.getEscrowAddress(platform, username);
|
|
254
|
+
// Get nonce
|
|
255
|
+
const nonce = await demos.getAddressNonce(refunder);
|
|
256
|
+
// Create empty transaction
|
|
257
|
+
let tx = structuredClone(skeletons.transaction);
|
|
258
|
+
// Build GCREdits
|
|
259
|
+
const gcrEdits = [
|
|
260
|
+
// 1. Refund escrow (checks expiry and depositor on node side)
|
|
261
|
+
{
|
|
262
|
+
type: "escrow",
|
|
263
|
+
operation: "refund",
|
|
264
|
+
account: escrowAddress,
|
|
265
|
+
data: {
|
|
266
|
+
refunder,
|
|
267
|
+
platform,
|
|
268
|
+
username,
|
|
269
|
+
},
|
|
270
|
+
txhash: "",
|
|
271
|
+
isRollback: false,
|
|
272
|
+
},
|
|
273
|
+
// 2. Add refund to original depositor
|
|
274
|
+
{
|
|
275
|
+
type: "balance",
|
|
276
|
+
operation: "add",
|
|
277
|
+
account: refunder,
|
|
278
|
+
amount: 0, // Placeholder - filled by node during validation
|
|
279
|
+
txhash: "",
|
|
280
|
+
isRollback: false,
|
|
281
|
+
},
|
|
282
|
+
];
|
|
283
|
+
// Fill transaction content
|
|
284
|
+
tx.content.from = refunder;
|
|
285
|
+
tx.content.to = escrowAddress;
|
|
286
|
+
tx.content.nonce = nonce + 1;
|
|
287
|
+
tx.content.amount = 0; // Amount filled by node
|
|
288
|
+
tx.content.type = "escrow";
|
|
289
|
+
tx.content.timestamp = Date.now();
|
|
290
|
+
tx.content.gcr_edits = gcrEdits;
|
|
291
|
+
tx.content.data = [
|
|
292
|
+
"escrow",
|
|
293
|
+
{
|
|
294
|
+
platform,
|
|
295
|
+
username,
|
|
296
|
+
operation: "refund",
|
|
297
|
+
},
|
|
298
|
+
];
|
|
299
|
+
// Sign transaction
|
|
300
|
+
return await demos.sign(tx);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
exports.EscrowTransaction = EscrowTransaction;
|
|
304
|
+
//# sourceMappingURL=EscrowTransaction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EscrowTransaction.js","sourceRoot":"","sources":["../../../src/escrow/EscrowTransaction.ts"],"names":[],"mappings":";AAAA;;;;;;;;;EASE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIF,kDAA8C;AAC9C,8DAA4D;AAC5D,oEAAqD;AAGrD;;;GAGG;AACH,MAAa,iBAAiB;IAC1B;;;;;;;OAOG;IACH,MAAM,CAAC,gBAAgB,CAAC,QAAgB,EAAE,QAAgB;QACtD,gDAAgD;QAChD,MAAM,QAAQ,GAAG,GAAG,QAAQ,IAAI,QAAQ,EAAE,CAAC,WAAW,EAAE,CAAA;QACxD,oDAAoD;QACpD,OAAO,iBAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;IACrC,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,MAAM,CAAC,KAAK,CAAC,cAAc,CACvB,KAAY,EACZ,QAA2C,EAC3C,QAAgB,EAChB,MAAc,EACd,OAGC;QAED,yCAAyC;QACzC,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,CAAA;QAC/D,MAAM,MAAM,GAAG,IAAA,+BAAe,EAAC,SAAuB,CAAC,CAAA;QAEvD,yBAAyB;QACzB,MAAM,aAAa,GAAG,IAAI,CAAC,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,C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labs, licensed under CC BY-NC-ND 4.0
|
|
5
|
+
|
|
6
|
+
Full license text: https://creativecommons.org/licenses/by-nc-nd/4.0/legalcode
|
|
7
|
+
Human readable license: https://creativecommons.org/licenses/by-nc-nd/4.0/
|
|
8
|
+
|
|
9
|
+
KyneSys Labs: https://www.kynesys.xyz/
|
|
10
|
+
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.EscrowQueries = exports.EscrowTransaction = void 0;
|
|
14
|
+
var EscrowTransaction_1 = require("./EscrowTransaction");
|
|
15
|
+
Object.defineProperty(exports, "EscrowTransaction", { enumerable: true, get: function () { return EscrowTransaction_1.EscrowTransaction; } });
|
|
16
|
+
var EscrowQueries_1 = require("./EscrowQueries");
|
|
17
|
+
Object.defineProperty(exports, "EscrowQueries", { enumerable: true, get: function () { return EscrowQueries_1.EscrowQueries; } });
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/escrow/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;EASE;;;AAEF,yDAAuD;AAA9C,sHAAA,iBAAiB,OAAA;AAC1B,iDAA+C;AAAtC,8GAAA,aAAa,OAAA"}
|
package/build/index.d.ts
CHANGED
package/build/index.js
CHANGED
|
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.storage = exports.instantMessaging = exports.bridge = exports.web2 = exports.abstraction = exports.websdk = exports.l2ps = exports.demoswork = exports.wallet = exports.xmcore = exports.xmwebsdk = exports.xmlocalsdk = exports.utils = exports.encryption = exports.types = void 0;
|
|
36
|
+
exports.escrow = exports.storage = exports.instantMessaging = exports.bridge = exports.web2 = exports.abstraction = exports.websdk = exports.l2ps = exports.demoswork = exports.wallet = exports.xmcore = exports.xmwebsdk = exports.xmlocalsdk = exports.utils = exports.encryption = exports.types = void 0;
|
|
37
37
|
// Common types and constants
|
|
38
38
|
exports.types = __importStar(require("./types"));
|
|
39
39
|
// Basic cryptographic and data manipulation functions
|
|
@@ -53,4 +53,5 @@ exports.web2 = __importStar(require("./websdk/Web2Calls"));
|
|
|
53
53
|
exports.bridge = __importStar(require("./bridge"));
|
|
54
54
|
exports.instantMessaging = __importStar(require("./instant_messaging"));
|
|
55
55
|
exports.storage = __importStar(require("./storage"));
|
|
56
|
+
exports.escrow = __importStar(require("./escrow"));
|
|
56
57
|
//# sourceMappingURL=index.js.map
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6BAA6B;AAC7B,iDAAgC;AAChC,sDAAsD;AACtD,2DAA0C;AAC1C,iDAAgC;AAEhC,gCAAgC;AAChC,oEAAmD;AACnD,gEAA+C;AAC/C,4DAA2C,CAAC,gCAAgC;AAE5E,mDAAkC;AAClC,yDAAwC;AAExC,+CAA8B;AAE9B,mDAAkC;AAClC,6DAA4C;AAC5C,2DAA0C;AAE1C,qCAAqC;AACrC,mDAAkC;AAElC,wEAAuD;AAEvD,qDAAoC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6BAA6B;AAC7B,iDAAgC;AAChC,sDAAsD;AACtD,2DAA0C;AAC1C,iDAAgC;AAEhC,gCAAgC;AAChC,oEAAmD;AACnD,gEAA+C;AAC/C,4DAA2C,CAAC,gCAAgC;AAE5E,mDAAkC;AAClC,yDAAwC;AAExC,+CAA8B;AAE9B,mDAAkC;AAClC,6DAA4C;AAC5C,2DAA0C;AAE1C,qCAAqC;AACrC,mDAAkC;AAElC,wEAAuD;AAEvD,qDAAoC;AAEpC,mDAAkC"}
|
|
@@ -116,4 +116,25 @@ export interface GCREditStorageProgram {
|
|
|
116
116
|
};
|
|
117
117
|
};
|
|
118
118
|
}
|
|
119
|
-
|
|
119
|
+
/**
|
|
120
|
+
* Escrow GCR edit operation
|
|
121
|
+
* Enables trustless escrow to social identities (Twitter, GitHub, Telegram)
|
|
122
|
+
*/
|
|
123
|
+
export interface GCREditEscrow {
|
|
124
|
+
type: "escrow";
|
|
125
|
+
operation: "deposit" | "claim" | "refund";
|
|
126
|
+
account: string;
|
|
127
|
+
data: {
|
|
128
|
+
sender?: string;
|
|
129
|
+
platform?: "twitter" | "github" | "telegram";
|
|
130
|
+
username?: string;
|
|
131
|
+
amount?: number;
|
|
132
|
+
expiryDays?: number;
|
|
133
|
+
message?: string;
|
|
134
|
+
claimant?: string;
|
|
135
|
+
refunder?: string;
|
|
136
|
+
};
|
|
137
|
+
txhash: string;
|
|
138
|
+
isRollback: boolean;
|
|
139
|
+
}
|
|
140
|
+
export type GCREdit = GCREditBalance | GCREditNonce | GCREditAssign | GCREditAssignIdentity | GCREditSubnetsTx | GCREditIdentity | GCREditSmartContract | GCREditStorageProgram | GCREditEscrow;
|
|
@@ -15,9 +15,10 @@ import { L2PSHashPayload } from "./TransactionSubtypes/L2PSHashTransaction";
|
|
|
15
15
|
import { ContractDeployPayload } from "./TransactionSubtypes/ContractDeployTransaction";
|
|
16
16
|
import { ContractCallPayload } from "./TransactionSubtypes/ContractCallTransaction";
|
|
17
17
|
import { D402PaymentPayload } from "./TransactionSubtypes/D402PaymentTransaction";
|
|
18
|
-
|
|
18
|
+
import { EscrowPayload } from "./TransactionSubtypes/EscrowTransaction";
|
|
19
|
+
export type TransactionContentData = ["web2Request", IWeb2Payload] | ["crosschainOperation", XMScript] | ["native", INativePayload] | ["demoswork", DemoScript] | ["l2psEncryptedTx", L2PSEncryptedPayload] | ["identity", IdentityPayload] | ["instantMessaging", InstantMessagingPayload] | ["nativeBridge", NativeBridgeTxPayload] | ["storage", StoragePayload] | ["storageProgram", StorageProgramPayload] | ["l2ps_hash_update", L2PSHashPayload] | ["contractDeploy", ContractDeployPayload] | ["contractCall", ContractCallPayload] | ["d402_payment", D402PaymentPayload] | ["escrow", EscrowPayload];
|
|
19
20
|
export interface TransactionContent {
|
|
20
|
-
type: "web2Request" | "crosschainOperation" | "subnet" | "native" | "demoswork" | "genesis" | "NODE_ONLINE" | "identity" | "instantMessaging" | "nativeBridge" | "l2psEncryptedTx" | "storage" | "storageProgram" | "l2ps_hash_update" | "contractDeploy" | "contractCall" | "d402_payment";
|
|
21
|
+
type: "web2Request" | "crosschainOperation" | "subnet" | "native" | "demoswork" | "genesis" | "NODE_ONLINE" | "identity" | "instantMessaging" | "nativeBridge" | "l2psEncryptedTx" | "storage" | "storageProgram" | "l2ps_hash_update" | "contractDeploy" | "contractCall" | "d402_payment" | "escrow";
|
|
21
22
|
from: string;
|
|
22
23
|
from_ed25519_address: string;
|
|
23
24
|
to: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Transaction.js","sourceRoot":"","sources":["../../../../src/types/blockchain/Transaction.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"Transaction.js","sourceRoot":"","sources":["../../../../src/types/blockchain/Transaction.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AA8FA,uCAAuC;AACvC,wDAAqC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Transaction, TransactionContent } from "../Transaction";
|
|
2
|
+
export interface EscrowPayload {
|
|
3
|
+
platform: string;
|
|
4
|
+
username: string;
|
|
5
|
+
amount?: string;
|
|
6
|
+
operation?: string;
|
|
7
|
+
}
|
|
8
|
+
export type EscrowTransactionContent = Omit<TransactionContent, 'type' | 'data'> & {
|
|
9
|
+
type: 'escrow';
|
|
10
|
+
data: ["escrow", EscrowPayload];
|
|
11
|
+
};
|
|
12
|
+
export interface EscrowTransaction extends Omit<Transaction, 'content'> {
|
|
13
|
+
content: EscrowTransactionContent;
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EscrowTransaction.js","sourceRoot":"","sources":["../../../../../src/types/blockchain/TransactionSubtypes/EscrowTransaction.ts"],"names":[],"mappings":""}
|
|
@@ -12,6 +12,7 @@ export * from './StorageProgramTransaction';
|
|
|
12
12
|
export * from './ContractDeployTransaction';
|
|
13
13
|
export * from './ContractCallTransaction';
|
|
14
14
|
export * from './D402PaymentTransaction';
|
|
15
|
+
export * from './EscrowTransaction';
|
|
15
16
|
import { L2PSTransaction } from './L2PSTransaction';
|
|
16
17
|
import { L2PSHashTransaction } from './L2PSHashTransaction';
|
|
17
18
|
import { Web2Transaction } from './Web2Transaction';
|
|
@@ -26,4 +27,5 @@ import { StorageProgramTransaction } from './StorageProgramTransaction';
|
|
|
26
27
|
import { ContractDeployTransaction } from './ContractDeployTransaction';
|
|
27
28
|
import { ContractCallTransaction } from './ContractCallTransaction';
|
|
28
29
|
import { D402PaymentTransaction } from './D402PaymentTransaction';
|
|
29
|
-
|
|
30
|
+
import { EscrowTransaction } from './EscrowTransaction';
|
|
31
|
+
export type SpecificTransaction = L2PSTransaction | L2PSHashTransaction | Web2Transaction | CrosschainTransaction | NativeTransaction | DemosworkTransaction | IdentityTransaction | InstantMessagingTransaction | NativeBridgeTransaction | StorageTransaction | StorageProgramTransaction | ContractDeployTransaction | ContractCallTransaction | D402PaymentTransaction | EscrowTransaction;
|
|
@@ -28,4 +28,5 @@ __exportStar(require("./StorageProgramTransaction"), exports);
|
|
|
28
28
|
__exportStar(require("./ContractDeployTransaction"), exports);
|
|
29
29
|
__exportStar(require("./ContractCallTransaction"), exports);
|
|
30
30
|
__exportStar(require("./D402PaymentTransaction"), exports);
|
|
31
|
+
__exportStar(require("./EscrowTransaction"), exports);
|
|
31
32
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/types/blockchain/TransactionSubtypes/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAiC;AACjC,wDAAqC;AACrC,oDAAiC;AACjC,0DAAuC;AACvC,sDAAmC;AACnC,yDAAsC;AACtC,wDAAqC;AACrC,gEAA6C;AAC7C,4DAAyC;AACzC,uDAAoC;AACpC,8DAA2C;AAC3C,8DAA2C;AAC3C,4DAAyC;AACzC,2DAAwC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/types/blockchain/TransactionSubtypes/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAiC;AACjC,wDAAqC;AACrC,oDAAiC;AACjC,0DAAuC;AACvC,sDAAmC;AACnC,yDAAsC;AACtC,wDAAqC;AACrC,gEAA6C;AAC7C,4DAAyC;AACzC,uDAAoC;AACpC,8DAA2C;AAC3C,8DAA2C;AAC3C,4DAAyC;AACzC,2DAAwC;AACxC,sDAAmC"}
|
package/package.json
CHANGED