@helium/helium-entity-manager-sdk 0.0.17 → 0.0.19
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/lib/cjs/functions/onboardIotHotspot.js +20 -40
- package/lib/cjs/functions/onboardIotHotspot.js.map +1 -1
- package/lib/cjs/functions/onboardMobileHotspot.js +20 -40
- package/lib/cjs/functions/onboardMobileHotspot.js.map +1 -1
- package/lib/cjs/functions/proofArgsAndAccounts.js +51 -0
- package/lib/cjs/functions/proofArgsAndAccounts.js.map +1 -0
- package/lib/cjs/functions/updateIotMetadata.js +20 -38
- package/lib/cjs/functions/updateIotMetadata.js.map +1 -1
- package/lib/cjs/functions/updateMobileMetadata.js +19 -36
- package/lib/cjs/functions/updateMobileMetadata.js.map +1 -1
- package/lib/cjs/index.js +3 -1
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/pdas.js +39 -2
- package/lib/cjs/pdas.js.map +1 -1
- package/lib/esm/src/functions/onboardIotHotspot.js +10 -29
- package/lib/esm/src/functions/onboardIotHotspot.js.map +1 -1
- package/lib/esm/src/functions/onboardMobileHotspot.js +10 -29
- package/lib/esm/src/functions/onboardMobileHotspot.js.map +1 -1
- package/lib/esm/src/functions/proofArgsAndAccounts.js +36 -0
- package/lib/esm/src/functions/proofArgsAndAccounts.js.map +1 -0
- package/lib/esm/src/functions/updateIotMetadata.js +10 -27
- package/lib/esm/src/functions/updateIotMetadata.js.map +1 -1
- package/lib/esm/src/functions/updateMobileMetadata.js +10 -27
- package/lib/esm/src/functions/updateMobileMetadata.js.map +1 -1
- package/lib/esm/src/index.js +1 -0
- package/lib/esm/src/index.js.map +1 -1
- package/lib/esm/src/pdas.js +12 -1
- package/lib/esm/src/pdas.js.map +1 -1
- package/lib/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/lib/types/src/functions/onboardIotHotspot.d.ts +4 -8
- package/lib/types/src/functions/onboardIotHotspot.d.ts.map +1 -1
- package/lib/types/src/functions/onboardMobileHotspot.d.ts +4 -7
- package/lib/types/src/functions/onboardMobileHotspot.d.ts.map +1 -1
- package/lib/types/src/functions/proofArgsAndAccounts.d.ts +20 -0
- package/lib/types/src/functions/proofArgsAndAccounts.d.ts.map +1 -0
- package/lib/types/src/functions/updateIotMetadata.d.ts +5 -8
- package/lib/types/src/functions/updateIotMetadata.d.ts.map +1 -1
- package/lib/types/src/functions/updateMobileMetadata.d.ts +3 -6
- package/lib/types/src/functions/updateMobileMetadata.d.ts.map +1 -1
- package/lib/types/src/index.d.ts +1 -0
- package/lib/types/src/index.d.ts.map +1 -1
- package/lib/types/src/pdas.d.ts +1 -0
- package/lib/types/src/pdas.d.ts.map +1 -1
- package/package.json +5 -5
- package/lib/cjs/functions/updateMetadata.js +0 -57
- package/lib/cjs/functions/updateMetadata.js.map +0 -1
- package/lib/cjs/utils.js +0 -25
- package/lib/cjs/utils.js.map +0 -1
- package/lib/esm/src/functions/updateMetadata.js +0 -42
- package/lib/esm/src/functions/updateMetadata.js.map +0 -1
- package/lib/esm/src/utils.js +0 -21
- package/lib/esm/src/utils.js.map +0 -1
- package/lib/types/src/functions/updateMetadata.d.ts +0 -133
- package/lib/types/src/functions/updateMetadata.d.ts.map +0 -1
- package/lib/types/src/utils.d.ts +0 -7
- package/lib/types/src/utils.d.ts.map +0 -1
|
@@ -8,55 +8,35 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
+
var t = {};
|
|
13
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
+
t[p] = s[p];
|
|
15
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
+
t[p[i]] = s[p[i]];
|
|
19
|
+
}
|
|
20
|
+
return t;
|
|
21
|
+
};
|
|
11
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
23
|
exports.onboardIotHotspot = void 0;
|
|
13
|
-
const spl_utils_1 = require("@helium/spl-utils");
|
|
14
|
-
const spl_account_compression_1 = require("@solana/spl-account-compression");
|
|
15
24
|
const pdas_1 = require("../pdas");
|
|
16
|
-
|
|
25
|
+
const proofArgsAndAccounts_1 = require("./proofArgsAndAccounts");
|
|
26
|
+
function onboardIotHotspot(_a) {
|
|
27
|
+
var { program, rewardableEntityConfig, assetId, maker, dao, dcFeePayer, payer } = _a, rest = __rest(_a, ["program", "rewardableEntityConfig", "assetId", "maker", "dao", "dcFeePayer", "payer"]);
|
|
17
28
|
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
-
|
|
19
|
-
const endpoint = assetEndpoint || program.provider.connection._rpcEndpoint;
|
|
20
|
-
const asset = yield getAssetFn(endpoint, assetId);
|
|
21
|
-
if (!asset) {
|
|
22
|
-
throw new Error("No asset with ID " + assetId.toBase58());
|
|
23
|
-
}
|
|
24
|
-
const assetProof = yield getAssetProofFn(endpoint, assetId);
|
|
25
|
-
if (!assetProof) {
|
|
26
|
-
throw new Error("No asset proof with ID " + assetId.toBase58());
|
|
27
|
-
}
|
|
28
|
-
const { root, proof, leaf, treeId, nodeIndex } = assetProof;
|
|
29
|
-
const { ownership: { owner }, content: { json_uri }, } = asset;
|
|
29
|
+
const { asset: { content: { json_uri }, ownership: { owner }, }, args, accounts, remainingAccounts, } = yield (0, proofArgsAndAccounts_1.proofArgsAndAccounts)(Object.assign({ connection: program.provider.connection, assetId }, rest));
|
|
30
30
|
const [info] = (0, pdas_1.iotInfoKey)(rewardableEntityConfig, assetId);
|
|
31
31
|
const makerAcc = yield program.account.makerV0.fetchNullable(maker);
|
|
32
|
-
const canopy = yield (yield spl_account_compression_1.ConcurrentMerkleTreeAccount.fromAccountAddress(program.provider.connection, treeId)).getCanopyDepth();
|
|
33
32
|
const keyToAsset = (yield (0, pdas_1.keyToAssetKey)(dao, json_uri.split("/").slice(-1)[0]))[0];
|
|
34
33
|
return program.methods
|
|
35
|
-
.onboardIotHotspotV0(
|
|
36
|
-
|
|
37
|
-
root: root.toBuffer().toJSON().data,
|
|
38
|
-
index: nodeIndex,
|
|
39
|
-
})
|
|
40
|
-
.accounts({
|
|
41
|
-
// hotspot: assetId,
|
|
42
|
-
payer,
|
|
34
|
+
.onboardIotHotspotV0(args)
|
|
35
|
+
.accounts(Object.assign(Object.assign({}, accounts), { payer,
|
|
43
36
|
dcFeePayer,
|
|
44
|
-
rewardableEntityConfig,
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
merkleTree: treeId,
|
|
48
|
-
maker,
|
|
49
|
-
dao,
|
|
50
|
-
issuingAuthority: makerAcc === null || makerAcc === void 0 ? void 0 : makerAcc.issuingAuthority,
|
|
51
|
-
keyToAsset,
|
|
52
|
-
})
|
|
53
|
-
.remainingAccounts(proof.slice(0, proof.length - canopy).map((p) => {
|
|
54
|
-
return {
|
|
55
|
-
pubkey: p,
|
|
56
|
-
isWritable: false,
|
|
57
|
-
isSigner: false,
|
|
58
|
-
};
|
|
59
|
-
}));
|
|
37
|
+
rewardableEntityConfig, hotspotOwner: owner, iotInfo: info, maker,
|
|
38
|
+
dao, issuingAuthority: makerAcc === null || makerAcc === void 0 ? void 0 : makerAcc.issuingAuthority, keyToAsset }))
|
|
39
|
+
.remainingAccounts(remainingAccounts);
|
|
60
40
|
});
|
|
61
41
|
}
|
|
62
42
|
exports.onboardIotHotspot = onboardIotHotspot;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"onboardIotHotspot.js","sourceRoot":"","sources":["../../../src/functions/onboardIotHotspot.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"onboardIotHotspot.js","sourceRoot":"","sources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;CACzC;AArDD,8CAqDC"}
|
|
@@ -8,54 +8,34 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
+
var t = {};
|
|
13
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
+
t[p] = s[p];
|
|
15
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
+
t[p[i]] = s[p[i]];
|
|
19
|
+
}
|
|
20
|
+
return t;
|
|
21
|
+
};
|
|
11
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
23
|
exports.onboardMobileHotspot = void 0;
|
|
13
|
-
const spl_utils_1 = require("@helium/spl-utils");
|
|
14
|
-
const spl_account_compression_1 = require("@solana/spl-account-compression");
|
|
15
24
|
const pdas_1 = require("../pdas");
|
|
16
|
-
|
|
25
|
+
const proofArgsAndAccounts_1 = require("./proofArgsAndAccounts");
|
|
26
|
+
function onboardMobileHotspot(_a) {
|
|
27
|
+
var { program, rewardableEntityConfig, assetId, maker, dao, payer, dcFeePayer } = _a, rest = __rest(_a, ["program", "rewardableEntityConfig", "assetId", "maker", "dao", "payer", "dcFeePayer"]);
|
|
17
28
|
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
-
|
|
19
|
-
const endpoint = assetEndpoint || program.provider.connection._rpcEndpoint;
|
|
20
|
-
const asset = yield getAssetFn(endpoint, assetId);
|
|
21
|
-
if (!asset) {
|
|
22
|
-
throw new Error("No asset with ID " + assetId.toBase58());
|
|
23
|
-
}
|
|
24
|
-
const assetProof = yield getAssetProofFn(endpoint, assetId);
|
|
25
|
-
if (!assetProof) {
|
|
26
|
-
throw new Error("No asset proof with ID " + assetId.toBase58());
|
|
27
|
-
}
|
|
28
|
-
const { root, proof, treeId, nodeIndex, leaf } = assetProof;
|
|
29
|
-
const { ownership: { owner }, content: { json_uri }, } = asset;
|
|
29
|
+
const { asset: { content: { json_uri }, ownership: { owner }, }, args, accounts, remainingAccounts, } = yield (0, proofArgsAndAccounts_1.proofArgsAndAccounts)(Object.assign({ connection: program.provider.connection, assetId }, rest));
|
|
30
30
|
const [info] = (0, pdas_1.mobileInfoKey)(rewardableEntityConfig, assetId);
|
|
31
|
-
const canopy = yield (yield spl_account_compression_1.ConcurrentMerkleTreeAccount.fromAccountAddress(program.provider.connection, treeId)).getCanopyDepth();
|
|
32
31
|
const makerAcc = yield program.account.makerV0.fetchNullable(maker);
|
|
33
32
|
return program.methods
|
|
34
|
-
.onboardMobileHotspotV0(
|
|
35
|
-
|
|
36
|
-
root: root.toBuffer().toJSON().data,
|
|
37
|
-
index: nodeIndex,
|
|
38
|
-
})
|
|
39
|
-
.accounts({
|
|
40
|
-
// hotspot: assetId,
|
|
41
|
-
dcFeePayer,
|
|
33
|
+
.onboardMobileHotspotV0(args)
|
|
34
|
+
.accounts(Object.assign(Object.assign({}, accounts), { dcFeePayer,
|
|
42
35
|
payer,
|
|
43
|
-
rewardableEntityConfig,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
merkleTree: treeId,
|
|
47
|
-
maker,
|
|
48
|
-
dao,
|
|
49
|
-
issuingAuthority: makerAcc === null || makerAcc === void 0 ? void 0 : makerAcc.issuingAuthority,
|
|
50
|
-
keyToAsset: (yield (0, pdas_1.keyToAssetKey)(dao, json_uri.split("/").slice(-1)[0]))[0],
|
|
51
|
-
})
|
|
52
|
-
.remainingAccounts(proof.slice(0, proof.length - canopy).map((p) => {
|
|
53
|
-
return {
|
|
54
|
-
pubkey: p,
|
|
55
|
-
isWritable: false,
|
|
56
|
-
isSigner: false,
|
|
57
|
-
};
|
|
58
|
-
}));
|
|
36
|
+
rewardableEntityConfig, hotspotOwner: owner, mobileInfo: info, maker,
|
|
37
|
+
dao, issuingAuthority: makerAcc === null || makerAcc === void 0 ? void 0 : makerAcc.issuingAuthority, keyToAsset: (yield (0, pdas_1.keyToAssetKey)(dao, json_uri.split("/").slice(-1)[0]))[0] }))
|
|
38
|
+
.remainingAccounts(remainingAccounts);
|
|
59
39
|
});
|
|
60
40
|
}
|
|
61
41
|
exports.onboardMobileHotspot = onboardMobileHotspot;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"onboardMobileHotspot.js","sourceRoot":"","sources":["../../../src/functions/onboardMobileHotspot.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"onboardMobileHotspot.js","sourceRoot":"","sources":["../../../src/functions/onboardMobileHotspot.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAGA,kCAAuD;AACvD,iEAAwF;AAExF,SAAsB,oBAAoB,CAAC,EAiBK;QAjBL,EACzC,OAAO,EACP,sBAAsB,EACtB,OAAO,EACP,KAAK,EACL,GAAG,EACH,KAAK,EACL,UAAU,OAUoC,EAT3C,IAAI,cARkC,uFAS1C,CADQ;;QAUP,MAAM,EACJ,KAAK,EAAE,EACL,OAAO,EAAE,EAAE,QAAQ,EAAE,EACrB,SAAS,EAAE,EAAE,KAAK,EAAE,GACrB,EACD,IAAI,EACJ,QAAQ,EACR,iBAAiB,GAClB,GAAG,MAAM,IAAA,2CAAoB,kBAC5B,UAAU,EAAE,OAAO,CAAC,QAAQ,CAAC,UAAU,EACvC,OAAO,IACJ,IAAI,EACP,CAAC;QAEH,MAAM,CAAC,IAAI,CAAC,GAAG,IAAA,oBAAa,EAAC,sBAAsB,EAAE,OAAO,CAAC,CAAC;QAC9D,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QAEpE,OAAO,OAAO,CAAC,OAAO;aACnB,sBAAsB,CAAC,IAAI,CAAC;aAC5B,QAAQ,iCAEJ,QAAQ,KACX,UAAU;YACV,KAAK;YACL,sBAAsB,EACtB,YAAY,EAAE,KAAK,EACnB,UAAU,EAAE,IAAI,EAChB,KAAK;YACL,GAAG,EACH,gBAAgB,EAAE,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,gBAAgB,EAC5C,UAAU,EAAE,CACV,MAAM,IAAA,oBAAa,EAAC,GAAG,EAAE,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAC3D,CAAC,CAAC,CAAC,IACJ;aACD,iBAAiB,CAAC,iBAAiB,CAAC,CAAC;;CACzC;AArDD,oDAqDC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.proofArgsAndAccounts = void 0;
|
|
13
|
+
const spl_utils_1 = require("@helium/spl-utils");
|
|
14
|
+
const spl_account_compression_1 = require("@solana/spl-account-compression");
|
|
15
|
+
function proofArgsAndAccounts({ connection, assetId, assetEndpoint, getAssetFn = spl_utils_1.getAsset, getAssetProofFn = spl_utils_1.getAssetProof, }) {
|
|
16
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
// @ts-ignore
|
|
18
|
+
const endpoint = assetEndpoint || connection._rpcEndpoint;
|
|
19
|
+
const asset = yield getAssetFn(endpoint, assetId);
|
|
20
|
+
if (!asset) {
|
|
21
|
+
throw new Error("No asset with ID " + assetId.toBase58());
|
|
22
|
+
}
|
|
23
|
+
const assetProof = yield getAssetProofFn(endpoint, assetId);
|
|
24
|
+
if (!assetProof) {
|
|
25
|
+
throw new Error("No asset proof with ID " + assetId.toBase58());
|
|
26
|
+
}
|
|
27
|
+
const { compression: { leafId }, } = asset;
|
|
28
|
+
const { root, proof, leaf, treeId } = assetProof;
|
|
29
|
+
const canopy = yield (yield spl_account_compression_1.ConcurrentMerkleTreeAccount.fromAccountAddress(connection, treeId)).getCanopyDepth();
|
|
30
|
+
return {
|
|
31
|
+
asset,
|
|
32
|
+
args: {
|
|
33
|
+
hash: leaf.toBuffer().toJSON().data,
|
|
34
|
+
root: root.toBuffer().toJSON().data,
|
|
35
|
+
index: leafId,
|
|
36
|
+
},
|
|
37
|
+
accounts: {
|
|
38
|
+
merkleTree: treeId,
|
|
39
|
+
},
|
|
40
|
+
remainingAccounts: proof.slice(0, proof.length - canopy).map((p) => {
|
|
41
|
+
return {
|
|
42
|
+
pubkey: p,
|
|
43
|
+
isWritable: false,
|
|
44
|
+
isSigner: false,
|
|
45
|
+
};
|
|
46
|
+
}),
|
|
47
|
+
};
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
exports.proofArgsAndAccounts = proofArgsAndAccounts;
|
|
51
|
+
//# sourceMappingURL=proofArgsAndAccounts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proofArgsAndAccounts.js","sourceRoot":"","sources":["../../../src/functions/proofArgsAndAccounts.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iDAA+E;AAC/E,6EAA8E;AAc9E,SAAsB,oBAAoB,CAAC,EACzC,UAAU,EACV,OAAO,EACP,aAAa,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,UAAU,EAAE,KAAK;oBACjB,QAAQ,EAAE,KAAK;iBAChB,CAAC;YACJ,CAAC,CAAC;SACH,CAAC;IACJ,CAAC;CAAA;AAvDD,oDAuDC"}
|
|
@@ -8,52 +8,34 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
+
var t = {};
|
|
13
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
+
t[p] = s[p];
|
|
15
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
+
t[p[i]] = s[p[i]];
|
|
19
|
+
}
|
|
20
|
+
return t;
|
|
21
|
+
};
|
|
11
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
23
|
exports.updateIotMetadata = void 0;
|
|
13
|
-
const spl_utils_1 = require("@helium/spl-utils");
|
|
14
|
-
const spl_account_compression_1 = require("@solana/spl-account-compression");
|
|
15
24
|
const pdas_1 = require("../pdas");
|
|
16
|
-
|
|
25
|
+
const proofArgsAndAccounts_1 = require("./proofArgsAndAccounts");
|
|
26
|
+
function updateIotMetadata(_a) {
|
|
27
|
+
var { program, rewardableEntityConfig, assetId, location, elevation, gain, payer, dcFeePayer } = _a, rest = __rest(_a, ["program", "rewardableEntityConfig", "assetId", "location", "elevation", "gain", "payer", "dcFeePayer"]);
|
|
17
28
|
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
-
|
|
19
|
-
const endpoint = assetEndpoint || program.provider.connection._rpcEndpoint;
|
|
20
|
-
const asset = yield getAssetFn(endpoint, assetId);
|
|
21
|
-
if (!asset) {
|
|
22
|
-
throw new Error("No asset with ID " + assetId.toBase58());
|
|
23
|
-
}
|
|
24
|
-
const assetProof = yield getAssetProofFn(endpoint, assetId);
|
|
25
|
-
if (!assetProof) {
|
|
26
|
-
throw new Error("No asset proof with ID " + assetId.toBase58());
|
|
27
|
-
}
|
|
28
|
-
const { root, proof, leaf, treeId, nodeIndex } = assetProof;
|
|
29
|
-
const { ownership: { owner }, } = asset;
|
|
29
|
+
const { asset: { ownership: { owner }, }, args, accounts, remainingAccounts, } = yield (0, proofArgsAndAccounts_1.proofArgsAndAccounts)(Object.assign({ connection: program.provider.connection, assetId }, rest));
|
|
30
30
|
const [info] = (0, pdas_1.iotInfoKey)(rewardableEntityConfig, assetId);
|
|
31
|
-
const canopy = yield (yield spl_account_compression_1.ConcurrentMerkleTreeAccount.fromAccountAddress(program.provider.connection, treeId)).getCanopyDepth();
|
|
32
31
|
return program.methods
|
|
33
|
-
.updateIotInfoV0({
|
|
34
|
-
location,
|
|
32
|
+
.updateIotInfoV0(Object.assign({ location,
|
|
35
33
|
elevation,
|
|
36
|
-
gain,
|
|
37
|
-
|
|
38
|
-
root: root.toBuffer().toJSON().data,
|
|
39
|
-
index: nodeIndex,
|
|
40
|
-
})
|
|
41
|
-
.accounts({
|
|
42
|
-
// hotspot: assetId,
|
|
43
|
-
payer,
|
|
34
|
+
gain }, args))
|
|
35
|
+
.accounts(Object.assign(Object.assign({}, accounts), { payer,
|
|
44
36
|
dcFeePayer,
|
|
45
|
-
rewardableEntityConfig,
|
|
46
|
-
|
|
47
|
-
iotInfo: info,
|
|
48
|
-
merkleTree: treeId,
|
|
49
|
-
})
|
|
50
|
-
.remainingAccounts(proof.slice(0, proof.length - canopy).map((p) => {
|
|
51
|
-
return {
|
|
52
|
-
pubkey: p,
|
|
53
|
-
isWritable: false,
|
|
54
|
-
isSigner: false,
|
|
55
|
-
};
|
|
56
|
-
}));
|
|
37
|
+
rewardableEntityConfig, hotspotOwner: owner, iotInfo: info }))
|
|
38
|
+
.remainingAccounts(remainingAccounts);
|
|
57
39
|
});
|
|
58
40
|
}
|
|
59
41
|
exports.updateIotMetadata = updateIotMetadata;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updateIotMetadata.js","sourceRoot":"","sources":["../../../src/functions/updateIotMetadata.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"updateIotMetadata.js","sourceRoot":"","sources":["../../../src/functions/updateIotMetadata.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAGA,kCAAqC;AACrC,iEAAwF;AAExF,SAAsB,iBAAiB,CAAC,EAmBQ;QAnBR,EACtC,OAAO,EACP,sBAAsB,EACtB,OAAO,EACP,QAAQ,EACR,SAAS,EACT,IAAI,EACJ,KAAK,EACL,UAAU,OAWoC,EAV3C,IAAI,cAT+B,wGAUvC,CADQ;;QAWP,MAAM,EACJ,KAAK,EAAE,EACL,SAAS,EAAE,EAAE,KAAK,EAAE,GACrB,EACD,IAAI,EACJ,QAAQ,EACR,iBAAiB,GAClB,GAAG,MAAM,IAAA,2CAAoB,kBAC5B,UAAU,EAAE,OAAO,CAAC,QAAQ,CAAC,UAAU,EACvC,OAAO,IACJ,IAAI,EACP,CAAC;QAEH,MAAM,CAAC,IAAI,CAAC,GAAG,IAAA,iBAAU,EAAC,sBAAsB,EAAE,OAAO,CAAC,CAAC;QAE3D,OAAO,OAAO,CAAC,OAAO;aACnB,eAAe,iBACd,QAAQ;YACR,SAAS;YACT,IAAI,IACD,IAAI,EACP;aACD,QAAQ,iCAEJ,QAAQ,KACX,KAAK;YACL,UAAU;YACV,sBAAsB,EACtB,YAAY,EAAE,KAAK,EACnB,OAAO,EAAE,IAAI,IACb;aACD,iBAAiB,CAAC,iBAAiB,CAAC,CAAC;;CACzC;AApDD,8CAoDC"}
|
|
@@ -8,49 +8,32 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
+
var t = {};
|
|
13
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
+
t[p] = s[p];
|
|
15
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
+
t[p[i]] = s[p[i]];
|
|
19
|
+
}
|
|
20
|
+
return t;
|
|
21
|
+
};
|
|
11
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
23
|
exports.updateMobileMetadata = void 0;
|
|
13
|
-
const spl_utils_1 = require("@helium/spl-utils");
|
|
14
|
-
const spl_account_compression_1 = require("@solana/spl-account-compression");
|
|
15
24
|
const pdas_1 = require("../pdas");
|
|
16
|
-
|
|
25
|
+
const proofArgsAndAccounts_1 = require("./proofArgsAndAccounts");
|
|
26
|
+
function updateMobileMetadata(_a) {
|
|
27
|
+
var { program, rewardableEntityConfig, assetId, location, dcFeePayer, payer } = _a, rest = __rest(_a, ["program", "rewardableEntityConfig", "assetId", "location", "dcFeePayer", "payer"]);
|
|
17
28
|
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
-
|
|
19
|
-
const endpoint = assetEndpoint || program.provider.connection._rpcEndpoint;
|
|
20
|
-
const asset = yield getAssetFn(endpoint, assetId);
|
|
21
|
-
if (!asset) {
|
|
22
|
-
throw new Error("No asset with ID " + assetId.toBase58());
|
|
23
|
-
}
|
|
24
|
-
const assetProof = yield getAssetProofFn(endpoint, assetId);
|
|
25
|
-
if (!assetProof) {
|
|
26
|
-
throw new Error("No asset proof with ID " + assetId.toBase58());
|
|
27
|
-
}
|
|
28
|
-
const { root, proof, leaf, treeId, nodeIndex } = assetProof;
|
|
29
|
-
const { ownership: { owner }, } = asset;
|
|
30
|
-
const canopy = yield (yield spl_account_compression_1.ConcurrentMerkleTreeAccount.fromAccountAddress(program.provider.connection, treeId)).getCanopyDepth();
|
|
29
|
+
const { asset: { content: { json_uri }, ownership: { owner }, }, args, accounts, remainingAccounts, } = yield (0, proofArgsAndAccounts_1.proofArgsAndAccounts)(Object.assign({ connection: program.provider.connection, assetId }, rest));
|
|
31
30
|
const [info] = (0, pdas_1.mobileInfoKey)(rewardableEntityConfig, assetId);
|
|
32
31
|
return program.methods
|
|
33
|
-
.updateMobileInfoV0({
|
|
34
|
-
|
|
35
|
-
hash: leaf.toBuffer().toJSON().data,
|
|
36
|
-
root: root.toBuffer().toJSON().data,
|
|
37
|
-
index: nodeIndex,
|
|
38
|
-
})
|
|
39
|
-
.accounts({
|
|
40
|
-
dcFeePayer,
|
|
32
|
+
.updateMobileInfoV0(Object.assign({ location }, args))
|
|
33
|
+
.accounts(Object.assign(Object.assign({}, accounts), { dcFeePayer,
|
|
41
34
|
payer,
|
|
42
|
-
rewardableEntityConfig,
|
|
43
|
-
|
|
44
|
-
mobileInfo: info,
|
|
45
|
-
merkleTree: treeId,
|
|
46
|
-
})
|
|
47
|
-
.remainingAccounts(proof.slice(0, proof.length - canopy).map((p) => {
|
|
48
|
-
return {
|
|
49
|
-
pubkey: p,
|
|
50
|
-
isWritable: false,
|
|
51
|
-
isSigner: false,
|
|
52
|
-
};
|
|
53
|
-
}));
|
|
35
|
+
rewardableEntityConfig, hotspotOwner: owner, mobileInfo: info }))
|
|
36
|
+
.remainingAccounts(remainingAccounts);
|
|
54
37
|
});
|
|
55
38
|
}
|
|
56
39
|
exports.updateMobileMetadata = updateMobileMetadata;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updateMobileMetadata.js","sourceRoot":"","sources":["../../../src/functions/updateMobileMetadata.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"updateMobileMetadata.js","sourceRoot":"","sources":["../../../src/functions/updateMobileMetadata.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAGA,kCAAwC;AACxC,iEAAwF;AAExF,SAAsB,oBAAoB,CAAC,EAeK;QAfL,EACzC,OAAO,EACP,sBAAsB,EACtB,OAAO,EACP,QAAQ,EACR,UAAU,EACV,KAAK,OASyC,EAR3C,IAAI,cAPkC,mFAQ1C,CADQ;;QASP,MAAM,EACJ,KAAK,EAAE,EACL,OAAO,EAAE,EAAE,QAAQ,EAAE,EACrB,SAAS,EAAE,EAAE,KAAK,EAAE,GACrB,EACD,IAAI,EACJ,QAAQ,EACR,iBAAiB,GAClB,GAAG,MAAM,IAAA,2CAAoB,kBAC5B,UAAU,EAAE,OAAO,CAAC,QAAQ,CAAC,UAAU,EACvC,OAAO,IACJ,IAAI,EACP,CAAC;QACH,MAAM,CAAC,IAAI,CAAC,GAAG,IAAA,oBAAa,EAAC,sBAAsB,EAAE,OAAO,CAAC,CAAC;QAE9D,OAAO,OAAO,CAAC,OAAO;aACnB,kBAAkB,iBACjB,QAAQ,IACL,IAAI,EACP;aACD,QAAQ,iCACJ,QAAQ,KACX,UAAU;YACV,KAAK;YACL,sBAAsB,EACtB,YAAY,EAAE,KAAK,EACnB,UAAU,EAAE,IAAI,IAChB;aACD,iBAAiB,CAAC,iBAAiB,CAAC,CAAC;;CACzC;AA7CD,oDA6CC"}
|
package/lib/cjs/index.js
CHANGED
|
@@ -23,7 +23,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
23
23
|
});
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.init = exports.onboardMobileHotspot = exports.onboardIotHotspot = exports.updateMobileMetadata = exports.updateIotMetadata = void 0;
|
|
26
|
+
exports.init = exports.proofArgsAndAccounts = exports.onboardMobileHotspot = exports.onboardIotHotspot = exports.updateMobileMetadata = exports.updateIotMetadata = void 0;
|
|
27
27
|
const anchor_1 = require("@project-serum/anchor");
|
|
28
28
|
const constants_1 = require("./constants");
|
|
29
29
|
const resolvers_1 = require("./resolvers");
|
|
@@ -38,6 +38,8 @@ var onboardIotHotspot_1 = require("./functions/onboardIotHotspot");
|
|
|
38
38
|
Object.defineProperty(exports, "onboardIotHotspot", { enumerable: true, get: function () { return onboardIotHotspot_1.onboardIotHotspot; } });
|
|
39
39
|
var onboardMobileHotspot_1 = require("./functions/onboardMobileHotspot");
|
|
40
40
|
Object.defineProperty(exports, "onboardMobileHotspot", { enumerable: true, get: function () { return onboardMobileHotspot_1.onboardMobileHotspot; } });
|
|
41
|
+
var proofArgsAndAccounts_1 = require("./functions/proofArgsAndAccounts");
|
|
42
|
+
Object.defineProperty(exports, "proofArgsAndAccounts", { enumerable: true, get: function () { return proofArgsAndAccounts_1.proofArgsAndAccounts; } });
|
|
41
43
|
const init = (provider, programId = constants_1.PROGRAM_ID, idl) => __awaiter(void 0, void 0, void 0, function* () {
|
|
42
44
|
if (!idl) {
|
|
43
45
|
idl = yield anchor_1.Program.fetchIdl(programId, provider);
|
package/lib/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAAqE;AAGrE,2CAAyC;AACzC,2CAA2D;AAC3D,yCAAuB;AACvB,8CAA4B;AAC5B,8CAA4B;AAC5B,mEAAkE;AAAzD,sHAAA,iBAAiB,OAAA;AAC1B,yEAAwE;AAA/D,4HAAA,oBAAoB,OAAA;AAC7B,mEAAkE;AAAzD,sHAAA,iBAAiB,OAAA;AAC1B,yEAAwE;AAA/D,4HAAA,oBAAoB,OAAA;AAEtB,MAAM,IAAI,GAAG,CAClB,QAAwB,EACxB,YAAuB,sBAAU,EACjC,GAAgB,EACuB,EAAE;IACzC,IAAI,CAAC,GAAG,EAAE;QACR,GAAG,GAAG,MAAM,gBAAO,CAAC,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;KACnD;IAED,MAAM,mBAAmB,GAAG,IAAI,gBAAO,CACrC,GAA0B,EAC1B,SAAS,EACT,QAAQ,EACR,SAAS,EACT,GAAG,EAAE,CAAC,wCAA4B,CACH,CAAC;IAElC,OAAO,mBAAmB,CAAC;AAC7B,CAAC,CAAA,CAAC;AAlBW,QAAA,IAAI,QAkBf"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAAqE;AAGrE,2CAAyC;AACzC,2CAA2D;AAC3D,yCAAuB;AACvB,8CAA4B;AAC5B,8CAA4B;AAC5B,mEAAkE;AAAzD,sHAAA,iBAAiB,OAAA;AAC1B,yEAAwE;AAA/D,4HAAA,oBAAoB,OAAA;AAC7B,mEAAkE;AAAzD,sHAAA,iBAAiB,OAAA;AAC1B,yEAAwE;AAA/D,4HAAA,oBAAoB,OAAA;AAC7B,yEAAwE;AAA/D,4HAAA,oBAAoB,OAAA;AAEtB,MAAM,IAAI,GAAG,CAClB,QAAwB,EACxB,YAAuB,sBAAU,EACjC,GAAgB,EACuB,EAAE;IACzC,IAAI,CAAC,GAAG,EAAE;QACR,GAAG,GAAG,MAAM,gBAAO,CAAC,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;KACnD;IAED,MAAM,mBAAmB,GAAG,IAAI,gBAAO,CACrC,GAA0B,EAC1B,SAAS,EACT,QAAQ,EACR,SAAS,EACT,GAAG,EAAE,CAAC,wCAA4B,CACH,CAAC;IAElC,OAAO,mBAAmB,CAAC;AAC7B,CAAC,CAAA,CAAC;AAlBW,QAAA,IAAI,QAkBf"}
|
package/lib/cjs/pdas.js
CHANGED
|
@@ -1,4 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
26
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
27
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -12,13 +35,25 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
35
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
36
|
};
|
|
14
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.collectionMetadataKey = exports.mobileInfoKey = exports.iotInfoKey = exports.keyToAssetKey = exports.makerKey = exports.hotspotCollectionKey = exports.rewardableEntityConfigKey = void 0;
|
|
38
|
+
exports.collectionMetadataKey = exports.mobileInfoKey = exports.iotInfoKey = exports.keyToAssetKey = exports.makerApprovalKey = exports.makerKey = exports.hotspotCollectionKey = exports.rewardableEntityConfigKey = void 0;
|
|
16
39
|
const web3_js_1 = require("@solana/web3.js");
|
|
17
40
|
const constants_1 = require("./constants");
|
|
18
41
|
const mpl_token_metadata_1 = require("@metaplex-foundation/mpl-token-metadata");
|
|
19
42
|
const crypto_1 = __importDefault(require("crypto"));
|
|
20
43
|
// @ts-ignore
|
|
21
44
|
const bs58_1 = __importDefault(require("bs58"));
|
|
45
|
+
function hashAnyhere(input) {
|
|
46
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
+
/// @ts-ignore
|
|
48
|
+
if (typeof window != "undefined") {
|
|
49
|
+
return crypto_1.default.subtle.digest("SHA-256", input);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
const { createHash } = yield Promise.resolve().then(() => __importStar(require("crypto")));
|
|
53
|
+
return createHash("sha256").update(input).digest();
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
22
57
|
const rewardableEntityConfigKey = (subDao, symbol, programId = constants_1.PROGRAM_ID) => web3_js_1.PublicKey.findProgramAddressSync([
|
|
23
58
|
Buffer.from("rewardable_entity_config", "utf-8"),
|
|
24
59
|
subDao.toBuffer(),
|
|
@@ -32,11 +67,13 @@ const makerKey = (name, programId = constants_1.PROGRAM_ID) => web3_js_1.PublicK
|
|
|
32
67
|
Buffer.from(name, "utf-8"),
|
|
33
68
|
], programId);
|
|
34
69
|
exports.makerKey = makerKey;
|
|
70
|
+
const makerApprovalKey = (rewardableEntityConfig, maker, programId = constants_1.PROGRAM_ID) => web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("maker_approval", "utf-8"), rewardableEntityConfig.toBuffer(), maker.toBuffer()], programId);
|
|
71
|
+
exports.makerApprovalKey = makerApprovalKey;
|
|
35
72
|
const keyToAssetKey = (dao, entityKey, programId = constants_1.PROGRAM_ID) => __awaiter(void 0, void 0, void 0, function* () {
|
|
36
73
|
if (typeof entityKey === "string") {
|
|
37
74
|
entityKey = Buffer.from(bs58_1.default.decode(entityKey));
|
|
38
75
|
}
|
|
39
|
-
const hash = yield
|
|
76
|
+
const hash = yield hashAnyhere(entityKey);
|
|
40
77
|
return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("key_to_asset", "utf-8"), dao.toBuffer(), Buffer.from(hash)], programId);
|
|
41
78
|
});
|
|
42
79
|
exports.keyToAssetKey = keyToAssetKey;
|
package/lib/cjs/pdas.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pdas.js","sourceRoot":"","sources":["../../src/pdas.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pdas.js","sourceRoot":"","sources":["../../src/pdas.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAA4C;AAC5C,2CAAyC;AACzC,gFAAkG;AAClG,oDAA4B;AAC5B,aAAa;AACb,gDAAwB;AAExB,SAAe,WAAW,CAAC,KAAa;;QACtC,cAAc;QACd,IAAI,OAAO,MAAM,IAAI,WAAW,EAAE;YAChC,OAAO,gBAAM,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;SAC/C;aAAM;YACL,MAAM,EAAE,UAAU,EAAE,GAAG,wDAAa,QAAQ,GAAC,CAAC;YAC9C,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,CAAA;SACnD;IACH,CAAC;CAAA;AAEM,MAAM,yBAAyB,GAAG,CACvC,MAAiB,EACjB,MAAc,EACd,YAAuB,sBAAU,EACjC,EAAE,CACF,mBAAS,CAAC,sBAAsB,CAC9B;IACE,MAAM,CAAC,IAAI,CAAC,0BAA0B,EAAE,OAAO,CAAC;IAChD,MAAM,CAAC,QAAQ,EAAE;IACjB,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC;CAC7B,EACD,SAAS,CACV,CAAC;A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,CAAC,QAAQ,EAAE,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,EACzE,SAAS,CACV,CAAC;AACJ,CAAC,CAAA,CAAC;AAdW,QAAA,aAAa,iBAcxB;AAEK,MAAM,UAAU,GAAG,CACxB,sBAAiC,EACjC,OAAkB,EAClB,YAAuB,sBAAU,EACjC,EAAE;IACF,OAAO,mBAAS,CAAC,sBAAsB,CACrC,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC,EAAE,sBAAsB,CAAC,QAAQ,EAAE,EAAE,OAAO,CAAC,QAAQ,EAAE,CAAC,EACzF,SAAS,CACV,CAAC;AACJ,CAAC,CAAC;AATW,QAAA,UAAU,cASrB;AAEK,MAAM,aAAa,GAAG,CAC3B,sBAAiC,EACjC,OAAkB,EAClB,YAAuB,sBAAU,EACjC,EAAE;IACF,OAAO,mBAAS,CAAC,sBAAsB,CACrC;QACE,MAAM,CAAC,IAAI,CAAC,aAAa,EAAE,OAAO,CAAC;QACnC,sBAAsB,CAAC,QAAQ,EAAE;QACjC,OAAO,CAAC,QAAQ,EAAE;KACnB,EACD,SAAS,CACV,CAAC;AACJ,CAAC,CAAC;AAbW,QAAA,aAAa,iBAaxB;AAEK,MAAM,qBAAqB,GAAG,CACnC,UAAqB,EACrB,YAAuB,+BAAyB,EAChD,EAAE,CACF,mBAAS,CAAC,sBAAsB,CAC9B;IACE,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC;IAChC,SAAS,CAAC,QAAQ,EAAE;IACpB,UAAU,CAAC,QAAQ,EAAE;CACtB,EACD,SAAS,CACV,CAAC;AAXS,QAAA,qBAAqB,yBAW9B"}
|
|
@@ -1,48 +1,29 @@
|
|
|
1
|
-
import { getAsset, getAssetProof } from "@helium/spl-utils";
|
|
2
|
-
import { ConcurrentMerkleTreeAccount } from "@solana/spl-account-compression";
|
|
3
1
|
import { iotInfoKey, keyToAssetKey } from "../pdas";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
const assetProof = await getAssetProofFn(endpoint, assetId);
|
|
12
|
-
if (!assetProof) {
|
|
13
|
-
throw new Error("No asset proof with ID " + assetId.toBase58());
|
|
14
|
-
}
|
|
15
|
-
const { root, proof, leaf, treeId, nodeIndex } = assetProof;
|
|
16
|
-
const { ownership: { owner }, content: { json_uri }, } = asset;
|
|
2
|
+
import { proofArgsAndAccounts } from "./proofArgsAndAccounts";
|
|
3
|
+
export async function onboardIotHotspot({ program, rewardableEntityConfig, assetId, maker, dao, dcFeePayer, payer, ...rest }) {
|
|
4
|
+
const { asset: { content: { json_uri }, ownership: { owner }, }, args, accounts, remainingAccounts, } = await proofArgsAndAccounts({
|
|
5
|
+
connection: program.provider.connection,
|
|
6
|
+
assetId,
|
|
7
|
+
...rest,
|
|
8
|
+
});
|
|
17
9
|
const [info] = iotInfoKey(rewardableEntityConfig, assetId);
|
|
18
10
|
const makerAcc = await program.account.makerV0.fetchNullable(maker);
|
|
19
|
-
const canopy = await (await ConcurrentMerkleTreeAccount.fromAccountAddress(program.provider.connection, treeId)).getCanopyDepth();
|
|
20
11
|
const keyToAsset = (await keyToAssetKey(dao, json_uri.split("/").slice(-1)[0]))[0];
|
|
21
12
|
return program.methods
|
|
22
|
-
.onboardIotHotspotV0(
|
|
23
|
-
hash: leaf.toBuffer().toJSON().data,
|
|
24
|
-
root: root.toBuffer().toJSON().data,
|
|
25
|
-
index: nodeIndex,
|
|
26
|
-
})
|
|
13
|
+
.onboardIotHotspotV0(args)
|
|
27
14
|
.accounts({
|
|
28
15
|
// hotspot: assetId,
|
|
16
|
+
...accounts,
|
|
29
17
|
payer,
|
|
30
18
|
dcFeePayer,
|
|
31
19
|
rewardableEntityConfig,
|
|
32
20
|
hotspotOwner: owner,
|
|
33
21
|
iotInfo: info,
|
|
34
|
-
merkleTree: treeId,
|
|
35
22
|
maker,
|
|
36
23
|
dao,
|
|
37
24
|
issuingAuthority: makerAcc?.issuingAuthority,
|
|
38
25
|
keyToAsset,
|
|
39
26
|
})
|
|
40
|
-
.remainingAccounts(
|
|
41
|
-
return {
|
|
42
|
-
pubkey: p,
|
|
43
|
-
isWritable: false,
|
|
44
|
-
isSigner: false,
|
|
45
|
-
};
|
|
46
|
-
}));
|
|
27
|
+
.remainingAccounts(remainingAccounts);
|
|
47
28
|
}
|
|
48
29
|
//# sourceMappingURL=onboardIotHotspot.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"onboardIotHotspot.js","sourceRoot":"","sources":["../../../../src/functions/onboardIotHotspot.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"onboardIotHotspot.js","sourceRoot":"","sources":["../../../../src/functions/onboardIotHotspot.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAA4B,MAAM,wBAAwB,CAAC;AAGxF,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,EACtC,OAAO,EACP,sBAAsB,EACtB,OAAO,EACP,KAAK,EACL,GAAG,EACH,UAAU,EACV,KAAK,EACL,GAAG,IAAI,EAQuC;IAC9C,MAAM,EACJ,KAAK,EAAE,EACL,OAAO,EAAE,EAAE,QAAQ,EAAE,EACrB,SAAS,EAAE,EAAE,KAAK,EAAE,GACrB,EACD,IAAI,EACJ,QAAQ,EACR,iBAAiB,GAClB,GAAG,MAAM,oBAAoB,CAAC;QAC7B,UAAU,EAAE,OAAO,CAAC,QAAQ,CAAC,UAAU;QACvC,OAAO;QACP,GAAG,IAAI;KACR,CAAC,CAAC;IAEH,MAAM,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,sBAAsB,EAAE,OAAO,CAAC,CAAC;IAC3D,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,KAAK,C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