Skip to content

Commit

Permalink
fix(icp): modify idl for deploying collection
Browse files Browse the repository at this point in the history
  • Loading branch information
imsk17 committed Oct 3, 2024
1 parent 0200ddb commit 10efbcc
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 20 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"@cosmjs/cosmwasm-stargate": "^0.32.3",
"@dfinity/agent": "^1.4.0",
"@dfinity/candid": "^1.4.0",
"@dfinity/identity": "^2.1.2",
"@dfinity/ledger-icp": "^2.3.1",
"@dfinity/nns": "^5.1.2",
"@dfinity/principal": "^1.4.0",
Expand Down
33 changes: 14 additions & 19 deletions src/handlers/icp/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { _SERVICE as BridgeService } from "../../contractsTypes/icp/bridge/bridg
import { idlFactory as LedgerIDL } from "../../contractsTypes/icp/ledger/ledger";
import { _SERVICE as LedgerService } from "../../contractsTypes/icp/ledger/ledger.types";
import { idlFactory as NftIdl } from "../../contractsTypes/icp/nft/nft";
import { init } from "../../contractsTypes/icp/nft/nft";
import { _SERVICE } from "../../contractsTypes/icp/nft/nft.types";
import { NftByteCode } from "./nft.wasm.gz.hex";
import { BrowserSigners, TICPHandler, TICPParams } from "./types";
Expand Down Expand Up @@ -168,31 +167,27 @@ export async function icpHandler({
return approval.Ok.toString();
},
async deployNftCollection(signer, _da) {
const encoded = init({ IDL })[0].encodeValue({
icrc3_args: [
const enc = IDL.encode(
[
IDL.Record({
owner: IDL.Principal,
name: IDL.Text,
symbol: IDL.Text,
}),
],
[
{
maxRecordsToArchive: 10_000,
archiveIndexType: {
Stable: [],
},
maxArchivePages: 62500,
settleToRecords: 2000,
archiveCycles: 2_000_000_000_000,
maxActiveRecords: 4000,
maxRecordsInArchiveInstance: 5_000_000,
archiveControllers: [],
supportedBlocks: [[]],
deployer: await signer.getPrincipal(),
owner: await signer.getPrincipal(),
name: _da.name,
symbol: _da.symbol,
},
],
icrc37_args: [],
icrc7_args: [],
});
);
const actor = await Actor.createAndInstallCanister(
NftIdl,
{
module: Buffer.from(NftByteCode, "hex"),
arg: encoded,
arg: enc,
},
{
agent: signer,
Expand Down
3 changes: 2 additions & 1 deletion src/handlers/icp/nft.wasm.gz.hex.ts

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,15 @@
resolved "https://registry.yarnpkg.com/@dfinity/candid/-/candid-1.4.0.tgz#76eb59f86025aae14e4c46672a4c8cd4950e8bf0"
integrity sha512-PsTJVn63ZM4A/6Xs5coI0zMFevSwJ8hcyh38LdH/92n6wi9UOTis1yc4qL5MZvvRCUAD0c3rVjELL+49E9sPyA==

"@dfinity/identity@^2.1.2":
version "2.1.2"
resolved "https://registry.yarnpkg.com/@dfinity/identity/-/identity-2.1.2.tgz#4f579ffada8ce140288dabbd72724237179530c5"
integrity sha512-LgskXJzyqm1UVsobAkF8bL1/SdLKFYW2kTIsKw7UOhuBy/COpnf3HZYmKeFCnxvharyIyq23W3WBhIpu9FeAvw==
dependencies:
"@noble/curves" "^1.2.0"
"@noble/hashes" "^1.3.1"
borc "^2.1.1"

"@dfinity/ledger-icp@^2.3.1":
version "2.3.1"
resolved "https://registry.yarnpkg.com/@dfinity/ledger-icp/-/ledger-icp-2.3.1.tgz#7807e56021e6f5cd57b50985ed70c32a0392e16e"
Expand Down Expand Up @@ -759,6 +768,13 @@
dependencies:
"@noble/hashes" "1.3.2"

"@noble/curves@^1.2.0":
version "1.6.0"
resolved "https://registry.yarnpkg.com/@noble/curves/-/curves-1.6.0.tgz#be5296ebcd5a1730fccea4786d420f87abfeb40b"
integrity sha512-TlaHRXDehJuRNR9TfZDNQ45mMEd5dwUwmicsafcIX4SsNiqnCHKjE/1alYPd/lDRVhxdhUAlv8uEhMCI5zjIJQ==
dependencies:
"@noble/hashes" "1.5.0"

"@noble/curves@^1.4.0", "@noble/curves@~1.4.0":
version "1.4.2"
resolved "https://registry.yarnpkg.com/@noble/curves/-/curves-1.4.2.tgz#40309198c76ed71bc6dbf7ba24e81ceb4d0d1fe9"
Expand Down Expand Up @@ -796,6 +812,11 @@
resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.4.0.tgz#45814aa329f30e4fe0ba49426f49dfccdd066426"
integrity sha512-V1JJ1WTRUqHHrOSh597hURcMqVKVGL/ea3kv0gSnEdsEZ0/+VyPghM1lMNGc00z7CIQorSvbKpuJkxvuHbvdbg==

"@noble/[email protected]":
version "1.5.0"
resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.5.0.tgz#abadc5ca20332db2b1b2aa3e496e9af1213570b0"
integrity sha512-1j6kQFb7QRru7eKN3ZDvRcP13rugwdxZqCjbiAVZfIJwgj2A65UmT4TgARXGlXgnRkORLTDTrO19ZErt7+QXgA==

"@noble/[email protected]":
version "1.7.0"
resolved "https://registry.yarnpkg.com/@noble/secp256k1/-/secp256k1-1.7.0.tgz#d15357f7c227e751d90aa06b05a0e5cf993ba8c1"
Expand Down

0 comments on commit 10efbcc

Please sign in to comment.