@silvana-one/nft 0.1.1 → 0.1.3
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/dist/node/contracts/collection.d.ts +6 -1
- package/dist/node/contracts/collection.js +6 -4
- package/dist/node/contracts/collection.js.map +1 -1
- package/dist/node/index.cjs +834 -590
- package/dist/node/index.d.ts +1 -0
- package/dist/node/index.js +1 -0
- package/dist/node/index.js.map +1 -1
- package/dist/node/interfaces/owner.d.ts +1 -1
- package/dist/node/interfaces/types.d.ts +2 -2
- package/dist/node/interfaces/types.js +2 -2
- package/dist/node/interfaces/types.js.map +1 -1
- package/dist/node/marketplace/auction.js +11 -2
- package/dist/node/marketplace/auction.js.map +1 -1
- package/dist/node/marketplace/nft-shares.js +6 -5
- package/dist/node/marketplace/nft-shares.js.map +1 -1
- package/dist/node/metadata/address.d.ts +38 -0
- package/dist/node/metadata/address.js +39 -0
- package/dist/node/metadata/address.js.map +1 -0
- package/dist/node/metadata/index.d.ts +1 -0
- package/dist/node/metadata/index.js +1 -0
- package/dist/node/metadata/index.js.map +1 -1
- package/dist/node/metadata/metadata.d.ts +37 -6
- package/dist/node/metadata/metadata.js +147 -4
- package/dist/node/metadata/metadata.js.map +1 -1
- package/dist/node/metadata/pin.d.ts +10 -0
- package/dist/node/metadata/pin.js +18 -0
- package/dist/node/metadata/pin.js.map +1 -0
- package/dist/node/metadata/tree.d.ts +1 -1
- package/dist/node/metadata/tree.js +2 -2
- package/dist/node/metadata/tree.js.map +1 -1
- package/dist/node/util/div.d.ts +62 -0
- package/dist/node/util/div.js +39 -0
- package/dist/node/util/div.js.map +1 -0
- package/dist/node/util/index.d.ts +1 -0
- package/dist/node/util/index.js +2 -0
- package/dist/node/util/index.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/tsconfig.web.tsbuildinfo +1 -1
- package/dist/web/contracts/collection.d.ts +6 -1
- package/dist/web/contracts/collection.js +6 -4
- package/dist/web/contracts/collection.js.map +1 -1
- package/dist/web/index.d.ts +1 -0
- package/dist/web/index.js +1 -0
- package/dist/web/index.js.map +1 -1
- package/dist/web/interfaces/owner.d.ts +1 -1
- package/dist/web/interfaces/types.d.ts +2 -2
- package/dist/web/interfaces/types.js +2 -2
- package/dist/web/interfaces/types.js.map +1 -1
- package/dist/web/marketplace/auction.js +11 -2
- package/dist/web/marketplace/auction.js.map +1 -1
- package/dist/web/marketplace/nft-shares.js +6 -5
- package/dist/web/marketplace/nft-shares.js.map +1 -1
- package/dist/web/metadata/address.d.ts +38 -0
- package/dist/web/metadata/address.js +39 -0
- package/dist/web/metadata/address.js.map +1 -0
- package/dist/web/metadata/index.d.ts +1 -0
- package/dist/web/metadata/index.js +1 -0
- package/dist/web/metadata/index.js.map +1 -1
- package/dist/web/metadata/metadata.d.ts +37 -6
- package/dist/web/metadata/metadata.js +147 -4
- package/dist/web/metadata/metadata.js.map +1 -1
- package/dist/web/metadata/pin.d.ts +10 -0
- package/dist/web/metadata/pin.js +18 -0
- package/dist/web/metadata/pin.js.map +1 -0
- package/dist/web/metadata/tree.d.ts +1 -1
- package/dist/web/metadata/tree.js +2 -2
- package/dist/web/metadata/tree.js.map +1 -1
- package/dist/web/util/div.d.ts +62 -0
- package/dist/web/util/div.js +39 -0
- package/dist/web/util/div.js.map +1 -0
- package/dist/web/util/index.d.ts +1 -0
- package/dist/web/util/index.js +2 -0
- package/dist/web/util/index.js.map +1 -0
- package/package.json +8 -8
- package/src/contracts/collection.ts +6 -4
- package/src/index.ts +1 -0
- package/src/interfaces/owner.ts +1 -1
- package/src/interfaces/types.ts +4 -4
- package/src/marketplace/auction.ts +13 -2
- package/src/marketplace/nft-shares.ts +7 -8
- package/src/metadata/address.ts +50 -0
- package/src/metadata/index.ts +1 -0
- package/src/metadata/metadata.ts +236 -11
- package/src/metadata/pin.ts +30 -0
- package/src/metadata/tree.ts +4 -3
- package/src/util/div.ts +44 -0
- package/src/util/index.ts +1 -0
package/dist/node/index.cjs
CHANGED
|
@@ -53,6 +53,7 @@ __export(index_exports, {
|
|
|
53
53
|
MintParams: () => MintParams,
|
|
54
54
|
MintParamsOption: () => MintParamsOption,
|
|
55
55
|
MintRequest: () => MintRequest,
|
|
56
|
+
MulDivResult: () => MulDivResult,
|
|
56
57
|
NFT: () => NFT,
|
|
57
58
|
NFTAddress: () => NFTAddress,
|
|
58
59
|
NFTAdmin: () => NFTAdmin,
|
|
@@ -93,7 +94,9 @@ __export(index_exports, {
|
|
|
93
94
|
WithdrawEvent: () => WithdrawEvent,
|
|
94
95
|
fieldFromString: () => fieldFromString,
|
|
95
96
|
fieldToString: () => fieldToString,
|
|
96
|
-
|
|
97
|
+
mulDiv: () => mulDiv,
|
|
98
|
+
nftVerificationKeys: () => nftVerificationKeys,
|
|
99
|
+
pinMetadata: () => pinMetadata
|
|
97
100
|
});
|
|
98
101
|
module.exports = __toCommonJS(index_exports);
|
|
99
102
|
|
|
@@ -374,7 +377,7 @@ var NFTData = class _NFTData extends (0, import_o1js.Struct)({
|
|
|
374
377
|
owner: typeof owner === "string" ? import_o1js.PublicKey.fromBase58(owner) : owner,
|
|
375
378
|
approved: approved ? typeof approved === "string" ? import_o1js.PublicKey.fromBase58(approved) : approved : import_o1js.PublicKey.empty(),
|
|
376
379
|
version: import_o1js.UInt32.from(version ?? 0),
|
|
377
|
-
id: import_o1js.UInt64.from(id ?? 0),
|
|
380
|
+
id: import_o1js.UInt64.from(BigInt(id ?? 0)),
|
|
378
381
|
canChangeOwnerByProof: (0, import_o1js.Bool)(canChangeOwnerByProof ?? false),
|
|
379
382
|
canTransfer: (0, import_o1js.Bool)(canTransfer ?? true),
|
|
380
383
|
canApprove: (0, import_o1js.Bool)(canApprove ?? true),
|
|
@@ -482,7 +485,7 @@ var CollectionData = class _CollectionData extends (0, import_o1js.Struct)({
|
|
|
482
485
|
const { royaltyFee, transferFee, requireTransferApproval, mintingIsLimited, isPaused } = params;
|
|
483
486
|
return new _CollectionData({
|
|
484
487
|
royaltyFee: import_o1js.UInt32.from(royaltyFee ?? 0),
|
|
485
|
-
transferFee: import_o1js.UInt64.from(transferFee ?? 0),
|
|
488
|
+
transferFee: import_o1js.UInt64.from(BigInt(transferFee ?? 0)),
|
|
486
489
|
requireTransferApproval: (0, import_o1js.Bool)(requireTransferApproval ?? false),
|
|
487
490
|
mintingIsLimited: (0, import_o1js.Bool)(mintingIsLimited ?? false),
|
|
488
491
|
isPaused: (0, import_o1js.Bool)(isPaused ?? false)
|
|
@@ -1406,7 +1409,7 @@ function NFTAdvancedAdminContract(params) {
|
|
|
1406
1409
|
|
|
1407
1410
|
// dist/node/contracts/collection.js
|
|
1408
1411
|
var import_tslib6 = require("tslib");
|
|
1409
|
-
var
|
|
1412
|
+
var import_o1js12 = require("o1js");
|
|
1410
1413
|
|
|
1411
1414
|
// dist/node/contracts/nft.js
|
|
1412
1415
|
var import_tslib5 = require("tslib");
|
|
@@ -1684,6 +1687,42 @@ var NFT = class extends import_o1js10.SmartContract {
|
|
|
1684
1687
|
(0, import_tslib5.__metadata)("design:returntype", Promise)
|
|
1685
1688
|
], NFT.prototype, "resume", null);
|
|
1686
1689
|
|
|
1690
|
+
// dist/node/util/div.js
|
|
1691
|
+
var import_o1js11 = require("o1js");
|
|
1692
|
+
var MulDivResult = class extends (0, import_o1js11.Struct)({
|
|
1693
|
+
result: import_o1js11.UInt64,
|
|
1694
|
+
remainder: import_o1js11.UInt64
|
|
1695
|
+
}) {
|
|
1696
|
+
};
|
|
1697
|
+
var MulDivResultInternal = class extends (0, import_o1js11.Struct)({
|
|
1698
|
+
result: import_o1js11.Field,
|
|
1699
|
+
remainder: import_o1js11.Field
|
|
1700
|
+
}) {
|
|
1701
|
+
};
|
|
1702
|
+
function mulDiv(params) {
|
|
1703
|
+
const { value, multiplier, denominator } = params;
|
|
1704
|
+
denominator.equals(import_o1js11.UInt64.zero).assertFalse("division by zero");
|
|
1705
|
+
const fields = import_o1js11.Provable.witness(MulDivResultInternal, () => {
|
|
1706
|
+
const valueBigInt = value.toBigInt();
|
|
1707
|
+
const multiplierBigInt = multiplier.toBigInt();
|
|
1708
|
+
const denominatorBigInt = denominator.toBigInt();
|
|
1709
|
+
if (denominatorBigInt === 0n) {
|
|
1710
|
+
return { result: import_o1js11.Field.from(0n), remainder: import_o1js11.Field.from(0n) };
|
|
1711
|
+
}
|
|
1712
|
+
const result = valueBigInt * multiplierBigInt / denominatorBigInt;
|
|
1713
|
+
const remainder = valueBigInt * multiplierBigInt - result * denominatorBigInt;
|
|
1714
|
+
return { result: import_o1js11.Field.from(result), remainder: import_o1js11.Field.from(remainder) };
|
|
1715
|
+
});
|
|
1716
|
+
import_o1js11.Gadgets.rangeCheck64(fields.result);
|
|
1717
|
+
import_o1js11.Gadgets.rangeCheck64(fields.remainder);
|
|
1718
|
+
fields.remainder.assertLessThan(denominator.value);
|
|
1719
|
+
fields.result.mul(denominator.value).add(fields.remainder).assertEquals(value.value.mul(multiplier.value));
|
|
1720
|
+
return {
|
|
1721
|
+
result: import_o1js11.UInt64.Unsafe.fromField(fields.result),
|
|
1722
|
+
remainder: import_o1js11.UInt64.Unsafe.fromField(fields.remainder)
|
|
1723
|
+
};
|
|
1724
|
+
}
|
|
1725
|
+
|
|
1687
1726
|
// dist/node/vk.js
|
|
1688
1727
|
var nftVerificationKeys = {
|
|
1689
1728
|
devnet: {
|
|
@@ -1734,32 +1773,32 @@ var CollectionErrors = {
|
|
|
1734
1773
|
};
|
|
1735
1774
|
function CollectionFactory(params) {
|
|
1736
1775
|
const { adminContract, ownerContract, approvalContract, updateContract } = params;
|
|
1737
|
-
class Collection2 extends
|
|
1776
|
+
class Collection2 extends import_o1js12.TokenContract {
|
|
1738
1777
|
constructor() {
|
|
1739
1778
|
super(...arguments);
|
|
1740
|
-
this.collectionName = (0,
|
|
1741
|
-
this.creator = (0,
|
|
1742
|
-
this.admin = (0,
|
|
1743
|
-
this.baseURL = (0,
|
|
1744
|
-
this.packedData = (0,
|
|
1779
|
+
this.collectionName = (0, import_o1js12.State)();
|
|
1780
|
+
this.creator = (0, import_o1js12.State)();
|
|
1781
|
+
this.admin = (0, import_o1js12.State)();
|
|
1782
|
+
this.baseURL = (0, import_o1js12.State)();
|
|
1783
|
+
this.packedData = (0, import_o1js12.State)();
|
|
1745
1784
|
this.events = {
|
|
1746
1785
|
mint: MintEvent,
|
|
1747
|
-
update:
|
|
1786
|
+
update: import_o1js12.PublicKey,
|
|
1748
1787
|
transfer: TransferEvent,
|
|
1749
1788
|
approve: ApproveEvent,
|
|
1750
1789
|
upgradeNFTVerificationKey: UpgradeVerificationKeyEvent,
|
|
1751
|
-
upgradeVerificationKey:
|
|
1790
|
+
upgradeVerificationKey: import_o1js12.Field,
|
|
1752
1791
|
limitMinting: LimitMintingEvent,
|
|
1753
1792
|
pause: PauseEvent,
|
|
1754
1793
|
resume: PauseEvent,
|
|
1755
1794
|
pauseNFT: PauseNFTEvent,
|
|
1756
1795
|
resumeNFT: PauseNFTEvent,
|
|
1757
1796
|
ownershipChange: OwnershipChangeEvent,
|
|
1758
|
-
setName:
|
|
1759
|
-
setBaseURL:
|
|
1760
|
-
setRoyaltyFee:
|
|
1761
|
-
setTransferFee:
|
|
1762
|
-
setAdmin:
|
|
1797
|
+
setName: import_o1js12.Field,
|
|
1798
|
+
setBaseURL: import_o1js12.Field,
|
|
1799
|
+
setRoyaltyFee: import_o1js12.UInt32,
|
|
1800
|
+
setTransferFee: import_o1js12.UInt64,
|
|
1801
|
+
setAdmin: import_o1js12.PublicKey
|
|
1763
1802
|
};
|
|
1764
1803
|
}
|
|
1765
1804
|
/**
|
|
@@ -1779,13 +1818,13 @@ function CollectionFactory(params) {
|
|
|
1779
1818
|
this.account.zkappUri.set(props.url);
|
|
1780
1819
|
this.account.tokenSymbol.set(props.symbol);
|
|
1781
1820
|
this.account.permissions.set({
|
|
1782
|
-
...
|
|
1783
|
-
setVerificationKey:
|
|
1784
|
-
setPermissions:
|
|
1785
|
-
access:
|
|
1786
|
-
send:
|
|
1787
|
-
setZkappUri:
|
|
1788
|
-
setTokenSymbol:
|
|
1821
|
+
...import_o1js12.Permissions.default(),
|
|
1822
|
+
setVerificationKey: import_o1js12.Permissions.VerificationKey.proofDuringCurrentVersion(),
|
|
1823
|
+
setPermissions: import_o1js12.Permissions.impossible(),
|
|
1824
|
+
access: import_o1js12.Permissions.proof(),
|
|
1825
|
+
send: import_o1js12.Permissions.proof(),
|
|
1826
|
+
setZkappUri: import_o1js12.Permissions.none(),
|
|
1827
|
+
setTokenSymbol: import_o1js12.Permissions.none()
|
|
1789
1828
|
});
|
|
1790
1829
|
}
|
|
1791
1830
|
/**
|
|
@@ -1795,8 +1834,8 @@ function CollectionFactory(params) {
|
|
|
1795
1834
|
* @param collectionData - Initial collection data including flags and configurations.
|
|
1796
1835
|
*/
|
|
1797
1836
|
async initialize(masterNFT, collectionData) {
|
|
1798
|
-
this.account.provedState.requireEquals((0,
|
|
1799
|
-
collectionData.royaltyFee.assertLessThanOrEqual(
|
|
1837
|
+
this.account.provedState.requireEquals((0, import_o1js12.Bool)(false));
|
|
1838
|
+
collectionData.royaltyFee.assertLessThanOrEqual(import_o1js12.UInt32.from(MAX_ROYALTY_FEE), CollectionErrors.invalidRoyaltyFee);
|
|
1800
1839
|
this.packedData.set(collectionData.pack());
|
|
1801
1840
|
masterNFT.address.equals(this.address).assertTrue(CollectionErrors.wrongMasterNFTaddress);
|
|
1802
1841
|
await this._mint(masterNFT);
|
|
@@ -1853,8 +1892,8 @@ function CollectionFactory(params) {
|
|
|
1853
1892
|
*/
|
|
1854
1893
|
async ensureCreatorSignature() {
|
|
1855
1894
|
const creator = this.creator.getAndRequireEquals();
|
|
1856
|
-
const creatorUpdate =
|
|
1857
|
-
creatorUpdate.body.useFullCommitment = (0,
|
|
1895
|
+
const creatorUpdate = import_o1js12.AccountUpdate.createSigned(creator);
|
|
1896
|
+
creatorUpdate.body.useFullCommitment = (0, import_o1js12.Bool)(true);
|
|
1858
1897
|
return creatorUpdate;
|
|
1859
1898
|
}
|
|
1860
1899
|
/**
|
|
@@ -1863,8 +1902,8 @@ function CollectionFactory(params) {
|
|
|
1863
1902
|
* @returns The AccountUpdate of the NFT owner.
|
|
1864
1903
|
*/
|
|
1865
1904
|
async ensureOwnerSignature(owner) {
|
|
1866
|
-
const ownerUpdate =
|
|
1867
|
-
ownerUpdate.body.useFullCommitment = (0,
|
|
1905
|
+
const ownerUpdate = import_o1js12.AccountUpdate.createSigned(owner);
|
|
1906
|
+
ownerUpdate.body.useFullCommitment = (0, import_o1js12.Bool)(true);
|
|
1868
1907
|
return ownerUpdate;
|
|
1869
1908
|
}
|
|
1870
1909
|
/**
|
|
@@ -1916,19 +1955,19 @@ function CollectionFactory(params) {
|
|
|
1916
1955
|
*/
|
|
1917
1956
|
async _mint(params2) {
|
|
1918
1957
|
const { name, address, data, metadata, storage, metadataVerificationKeyHash, expiry } = params2;
|
|
1919
|
-
this.network.globalSlotSinceGenesis.requireBetween(
|
|
1920
|
-
data.version.assertEquals(
|
|
1958
|
+
this.network.globalSlotSinceGenesis.requireBetween(import_o1js12.UInt32.zero, expiry);
|
|
1959
|
+
data.version.assertEquals(import_o1js12.UInt32.zero);
|
|
1921
1960
|
const packedData = data.pack();
|
|
1922
1961
|
const tokenId = this.deriveTokenId();
|
|
1923
|
-
const update =
|
|
1924
|
-
update.body.useFullCommitment = (0,
|
|
1962
|
+
const update = import_o1js12.AccountUpdate.createSigned(address, tokenId);
|
|
1963
|
+
update.body.useFullCommitment = (0, import_o1js12.Bool)(true);
|
|
1925
1964
|
update.account.isNew.getAndRequireEquals().assertTrue();
|
|
1926
1965
|
this.internal.mint({ address: update, amount: 1e9 });
|
|
1927
|
-
const verificationKey =
|
|
1928
|
-
const networkId =
|
|
1929
|
-
const verificationKey2 = new
|
|
1966
|
+
const verificationKey = import_o1js12.Provable.witness(import_o1js12.VerificationKey, () => {
|
|
1967
|
+
const networkId = import_o1js12.Mina.getNetworkId() === "mainnet" ? "mainnet" : "devnet";
|
|
1968
|
+
const verificationKey2 = new import_o1js12.VerificationKey({
|
|
1930
1969
|
data: nftVerificationKeys[networkId].vk.NFT.data,
|
|
1931
|
-
hash: (0,
|
|
1970
|
+
hash: (0, import_o1js12.Field)(nftVerificationKeys[networkId].vk.NFT.hash)
|
|
1932
1971
|
});
|
|
1933
1972
|
const vkHash = NFT._verificationKey?.hash;
|
|
1934
1973
|
if (!verificationKey2 || !verificationKey2.hash || !verificationKey2.data)
|
|
@@ -1937,29 +1976,29 @@ function CollectionFactory(params) {
|
|
|
1937
1976
|
throw Error("NFT verification key does not match the compiled verification key");
|
|
1938
1977
|
return verificationKey2;
|
|
1939
1978
|
});
|
|
1940
|
-
const mainnetVerificationKeyHash = (0,
|
|
1941
|
-
const devnetVerificationKeyHash = (0,
|
|
1942
|
-
const isMainnet =
|
|
1943
|
-
return (0,
|
|
1979
|
+
const mainnetVerificationKeyHash = (0, import_o1js12.Field)(nftVerificationKeys.mainnet.vk.NFT.hash);
|
|
1980
|
+
const devnetVerificationKeyHash = (0, import_o1js12.Field)(nftVerificationKeys.devnet.vk.NFT.hash);
|
|
1981
|
+
const isMainnet = import_o1js12.Provable.witness(import_o1js12.Bool, () => {
|
|
1982
|
+
return (0, import_o1js12.Bool)(import_o1js12.Mina.getNetworkId() === "mainnet");
|
|
1944
1983
|
});
|
|
1945
|
-
verificationKey.hash.assertEquals(
|
|
1984
|
+
verificationKey.hash.assertEquals(import_o1js12.Provable.if(isMainnet, mainnetVerificationKeyHash, devnetVerificationKeyHash));
|
|
1946
1985
|
update.body.update.verificationKey = {
|
|
1947
|
-
isSome: (0,
|
|
1986
|
+
isSome: (0, import_o1js12.Bool)(true),
|
|
1948
1987
|
value: verificationKey
|
|
1949
1988
|
};
|
|
1950
1989
|
update.body.update.permissions = {
|
|
1951
|
-
isSome: (0,
|
|
1990
|
+
isSome: (0, import_o1js12.Bool)(true),
|
|
1952
1991
|
value: {
|
|
1953
|
-
...
|
|
1992
|
+
...import_o1js12.Permissions.default(),
|
|
1954
1993
|
// NFT cannot be sent to other accounts, only owner can be changed
|
|
1955
|
-
send:
|
|
1994
|
+
send: import_o1js12.Permissions.impossible(),
|
|
1956
1995
|
// Allow the upgrade authority to set the verification key
|
|
1957
1996
|
// even when there is no protocol upgrade
|
|
1958
|
-
setVerificationKey:
|
|
1959
|
-
setPermissions:
|
|
1960
|
-
access:
|
|
1961
|
-
setZkappUri:
|
|
1962
|
-
setTokenSymbol:
|
|
1997
|
+
setVerificationKey: import_o1js12.Permissions.VerificationKey.proofDuringCurrentVersion(),
|
|
1998
|
+
setPermissions: import_o1js12.Permissions.impossible(),
|
|
1999
|
+
access: import_o1js12.Permissions.proof(),
|
|
2000
|
+
setZkappUri: import_o1js12.Permissions.impossible(),
|
|
2001
|
+
setTokenSymbol: import_o1js12.Permissions.impossible()
|
|
1963
2002
|
}
|
|
1964
2003
|
};
|
|
1965
2004
|
const initialState = new NFTStateStruct({
|
|
@@ -1970,7 +2009,7 @@ function CollectionFactory(params) {
|
|
|
1970
2009
|
metadataVerificationKeyHash
|
|
1971
2010
|
});
|
|
1972
2011
|
update.body.update.appState = NFTStateStruct.toFields(initialState).map((field) => ({
|
|
1973
|
-
isSome: (0,
|
|
2012
|
+
isSome: (0, import_o1js12.Bool)(true),
|
|
1974
2013
|
value: field
|
|
1975
2014
|
}));
|
|
1976
2015
|
const event = new MintEvent({
|
|
@@ -1997,7 +2036,7 @@ function CollectionFactory(params) {
|
|
|
1997
2036
|
*/
|
|
1998
2037
|
async updateWithOracle(proof, vk) {
|
|
1999
2038
|
const oracleAddress = proof.publicInput.oracleAddress;
|
|
2000
|
-
oracleAddress.equals(
|
|
2039
|
+
oracleAddress.equals(import_o1js12.PublicKey.empty()).assertFalse(CollectionErrors.invalidOracleAddress);
|
|
2001
2040
|
const oracle = this.getUpdateContract(oracleAddress);
|
|
2002
2041
|
const canUpdate = await oracle.canUpdate(this.address, proof.publicInput.immutableState.address, proof.publicInput, proof.publicOutput);
|
|
2003
2042
|
canUpdate.assertTrue();
|
|
@@ -2068,7 +2107,7 @@ function CollectionFactory(params) {
|
|
|
2068
2107
|
collectionData.isPaused.assertFalse(CollectionErrors.collectionPaused);
|
|
2069
2108
|
collectionData.requireTransferApproval.assertFalse(CollectionErrors.transferApprovalRequired);
|
|
2070
2109
|
const transferEventDraft = new TransferExtendedParams({
|
|
2071
|
-
from:
|
|
2110
|
+
from: import_o1js12.PublicKey.empty(),
|
|
2072
2111
|
// will be added later
|
|
2073
2112
|
to,
|
|
2074
2113
|
collection: this.address,
|
|
@@ -2076,9 +2115,9 @@ function CollectionFactory(params) {
|
|
|
2076
2115
|
fee: UInt64Option.none(),
|
|
2077
2116
|
// will be added later
|
|
2078
2117
|
price,
|
|
2079
|
-
transferByOwner: (0,
|
|
2118
|
+
transferByOwner: (0, import_o1js12.Bool)(false),
|
|
2080
2119
|
// will be added later
|
|
2081
|
-
approved:
|
|
2120
|
+
approved: import_o1js12.PublicKey.empty(),
|
|
2082
2121
|
// will be added later
|
|
2083
2122
|
context
|
|
2084
2123
|
});
|
|
@@ -2107,9 +2146,9 @@ function CollectionFactory(params) {
|
|
|
2107
2146
|
fee: UInt64Option.none(),
|
|
2108
2147
|
// will be added later
|
|
2109
2148
|
price,
|
|
2110
|
-
transferByOwner: (0,
|
|
2149
|
+
transferByOwner: (0, import_o1js12.Bool)(false),
|
|
2111
2150
|
// will be added later
|
|
2112
|
-
approved:
|
|
2151
|
+
approved: import_o1js12.PublicKey.empty(),
|
|
2113
2152
|
// will be added later
|
|
2114
2153
|
context
|
|
2115
2154
|
});
|
|
@@ -2141,9 +2180,9 @@ function CollectionFactory(params) {
|
|
|
2141
2180
|
fee: UInt64Option.none(),
|
|
2142
2181
|
// will be added later
|
|
2143
2182
|
price,
|
|
2144
|
-
transferByOwner: (0,
|
|
2183
|
+
transferByOwner: (0, import_o1js12.Bool)(false),
|
|
2145
2184
|
// will be added later
|
|
2146
|
-
approved:
|
|
2185
|
+
approved: import_o1js12.PublicKey.empty(),
|
|
2147
2186
|
// will be added later
|
|
2148
2187
|
context
|
|
2149
2188
|
});
|
|
@@ -2171,7 +2210,7 @@ function CollectionFactory(params) {
|
|
|
2171
2210
|
const collectionData = CollectionData.unpack(this.packedData.getAndRequireEquals());
|
|
2172
2211
|
collectionData.isPaused.assertFalse(CollectionErrors.collectionPaused);
|
|
2173
2212
|
const transferEventDraft = new TransferExtendedParams({
|
|
2174
|
-
from:
|
|
2213
|
+
from: import_o1js12.PublicKey.empty(),
|
|
2175
2214
|
// will be added later
|
|
2176
2215
|
to,
|
|
2177
2216
|
collection: this.address,
|
|
@@ -2179,9 +2218,9 @@ function CollectionFactory(params) {
|
|
|
2179
2218
|
fee: UInt64Option.none(),
|
|
2180
2219
|
// will be added later
|
|
2181
2220
|
price,
|
|
2182
|
-
transferByOwner: (0,
|
|
2221
|
+
transferByOwner: (0, import_o1js12.Bool)(false),
|
|
2183
2222
|
// will be added later
|
|
2184
|
-
approved:
|
|
2223
|
+
approved: import_o1js12.PublicKey.empty(),
|
|
2185
2224
|
// will be added later
|
|
2186
2225
|
context
|
|
2187
2226
|
});
|
|
@@ -2206,38 +2245,42 @@ function CollectionFactory(params) {
|
|
|
2206
2245
|
async _transfer(params2) {
|
|
2207
2246
|
const { transferEventDraft, transferFee, royaltyFee } = params2;
|
|
2208
2247
|
const sender = this.sender.getUnconstrained();
|
|
2209
|
-
const isFromEmpty = transferEventDraft.from.equals(
|
|
2210
|
-
transferEventDraft.from =
|
|
2248
|
+
const isFromEmpty = transferEventDraft.from.equals(import_o1js12.PublicKey.empty());
|
|
2249
|
+
transferEventDraft.from = import_o1js12.Provable.if(isFromEmpty, sender, transferEventDraft.from);
|
|
2211
2250
|
const tokenId = this.deriveTokenId();
|
|
2212
2251
|
const nft = new NFT(transferEventDraft.nft, tokenId);
|
|
2213
2252
|
const transferEvent = await nft.transfer(transferEventDraft);
|
|
2214
2253
|
const creator = this.creator.getAndRequireEquals();
|
|
2215
|
-
let fee =
|
|
2254
|
+
let fee = import_o1js12.Provable.if(
|
|
2216
2255
|
transferEventDraft.price.isSome,
|
|
2217
2256
|
// We cannot check the price here, so we just rely on owner contract
|
|
2218
2257
|
// Malicious owner contracts can be blocked by the admin contract
|
|
2219
2258
|
// or by setting the transfer fee to a higher value reflecting the market price
|
|
2220
|
-
|
|
2259
|
+
mulDiv({
|
|
2260
|
+
value: transferEventDraft.price.value,
|
|
2261
|
+
multiplier: import_o1js12.UInt64.from(royaltyFee),
|
|
2262
|
+
denominator: import_o1js12.UInt64.from(MAX_ROYALTY_FEE)
|
|
2263
|
+
}).result,
|
|
2221
2264
|
transferFee
|
|
2222
2265
|
);
|
|
2223
2266
|
const isOwnedByCreator = transferEvent.from.equals(creator);
|
|
2224
|
-
fee =
|
|
2267
|
+
fee = import_o1js12.Provable.if(
|
|
2225
2268
|
isOwnedByCreator,
|
|
2226
|
-
|
|
2269
|
+
import_o1js12.UInt64.zero,
|
|
2227
2270
|
// The minimum fee is the transfer fee
|
|
2228
|
-
|
|
2271
|
+
import_o1js12.Provable.if(fee.lessThanOrEqual(transferFee), transferFee, fee)
|
|
2229
2272
|
);
|
|
2230
|
-
const senderUpdate =
|
|
2273
|
+
const senderUpdate = import_o1js12.AccountUpdate.createIf(fee.equals(import_o1js12.UInt64.zero).not().or(isFromEmpty), sender);
|
|
2231
2274
|
senderUpdate.requireSignature();
|
|
2232
|
-
senderUpdate.body.useFullCommitment = (0,
|
|
2233
|
-
senderUpdate.account.balance.requireBetween(fee,
|
|
2275
|
+
senderUpdate.body.useFullCommitment = (0, import_o1js12.Bool)(true);
|
|
2276
|
+
senderUpdate.account.balance.requireBetween(fee, import_o1js12.UInt64.MAXINT());
|
|
2234
2277
|
senderUpdate.send({
|
|
2235
2278
|
to: this.creator.getAndRequireEquals(),
|
|
2236
2279
|
amount: fee
|
|
2237
2280
|
});
|
|
2238
2281
|
transferEvent.fee = UInt64Option.fromValue({
|
|
2239
2282
|
value: fee,
|
|
2240
|
-
isSome: fee.equals(
|
|
2283
|
+
isSome: fee.equals(import_o1js12.UInt64.zero).not()
|
|
2241
2284
|
});
|
|
2242
2285
|
this.emitEvent("transfer", new TransferEvent({
|
|
2243
2286
|
...transferEvent
|
|
@@ -2301,9 +2344,9 @@ function CollectionFactory(params) {
|
|
|
2301
2344
|
await this.ensureCreatorSignature();
|
|
2302
2345
|
const collectionData = CollectionData.unpack(this.packedData.getAndRequireEquals());
|
|
2303
2346
|
collectionData.isPaused.assertFalse(CollectionErrors.collectionPaused);
|
|
2304
|
-
collectionData.mintingIsLimited = (0,
|
|
2347
|
+
collectionData.mintingIsLimited = (0, import_o1js12.Bool)(true);
|
|
2305
2348
|
this.packedData.set(collectionData.pack());
|
|
2306
|
-
this.emitEvent("limitMinting", new LimitMintingEvent({ mintingLimited: (0,
|
|
2349
|
+
this.emitEvent("limitMinting", new LimitMintingEvent({ mintingLimited: (0, import_o1js12.Bool)(true) }));
|
|
2307
2350
|
}
|
|
2308
2351
|
/**
|
|
2309
2352
|
* Pauses the collection, disabling certain actions.
|
|
@@ -2314,9 +2357,9 @@ function CollectionFactory(params) {
|
|
|
2314
2357
|
const adminContract2 = this.getAdminContract();
|
|
2315
2358
|
const canPause = await adminContract2.canPause();
|
|
2316
2359
|
canPause.assertTrue(CollectionErrors.noPermissionToPause);
|
|
2317
|
-
collectionData.isPaused = (0,
|
|
2360
|
+
collectionData.isPaused = (0, import_o1js12.Bool)(true);
|
|
2318
2361
|
this.packedData.set(collectionData.pack());
|
|
2319
|
-
this.emitEvent("pause", new PauseEvent({ isPaused: (0,
|
|
2362
|
+
this.emitEvent("pause", new PauseEvent({ isPaused: (0, import_o1js12.Bool)(true) }));
|
|
2320
2363
|
}
|
|
2321
2364
|
/**
|
|
2322
2365
|
* Resumes the collection, re-enabling actions.
|
|
@@ -2327,9 +2370,9 @@ function CollectionFactory(params) {
|
|
|
2327
2370
|
const adminContract2 = this.getAdminContract();
|
|
2328
2371
|
const canResume = await adminContract2.canResume();
|
|
2329
2372
|
canResume.assertTrue(CollectionErrors.noPermissionToResume);
|
|
2330
|
-
collectionData.isPaused = (0,
|
|
2373
|
+
collectionData.isPaused = (0, import_o1js12.Bool)(false);
|
|
2331
2374
|
this.packedData.set(collectionData.pack());
|
|
2332
|
-
this.emitEvent("resume", new PauseEvent({ isPaused: (0,
|
|
2375
|
+
this.emitEvent("resume", new PauseEvent({ isPaused: (0, import_o1js12.Bool)(false) }));
|
|
2333
2376
|
}
|
|
2334
2377
|
/**
|
|
2335
2378
|
* Pauses a specific NFT, disabling its actions.
|
|
@@ -2341,7 +2384,7 @@ function CollectionFactory(params) {
|
|
|
2341
2384
|
const nft = new NFT(address, tokenId);
|
|
2342
2385
|
const owner = await nft.pause();
|
|
2343
2386
|
await this.ensureOwnerSignature(owner);
|
|
2344
|
-
this.emitEvent("pauseNFT", new PauseNFTEvent({ isPaused: (0,
|
|
2387
|
+
this.emitEvent("pauseNFT", new PauseNFTEvent({ isPaused: (0, import_o1js12.Bool)(true), address }));
|
|
2345
2388
|
}
|
|
2346
2389
|
/**
|
|
2347
2390
|
* Pauses a specific NFT, disabling its actions.
|
|
@@ -2355,7 +2398,7 @@ function CollectionFactory(params) {
|
|
|
2355
2398
|
const ownerContract2 = this.getOwnerContract(owner);
|
|
2356
2399
|
const canPause = await ownerContract2.canPause(this.address, address);
|
|
2357
2400
|
canPause.assertTrue();
|
|
2358
|
-
this.emitEvent("pauseNFT", new PauseNFTEvent({ isPaused: (0,
|
|
2401
|
+
this.emitEvent("pauseNFT", new PauseNFTEvent({ isPaused: (0, import_o1js12.Bool)(true), address }));
|
|
2359
2402
|
}
|
|
2360
2403
|
/**
|
|
2361
2404
|
* Resumes a specific NFT, re-enabling its actions.
|
|
@@ -2367,7 +2410,7 @@ function CollectionFactory(params) {
|
|
|
2367
2410
|
const nft = new NFT(address, tokenId);
|
|
2368
2411
|
const owner = await nft.resume();
|
|
2369
2412
|
await this.ensureOwnerSignature(owner);
|
|
2370
|
-
this.emitEvent("resumeNFT", new PauseNFTEvent({ isPaused: (0,
|
|
2413
|
+
this.emitEvent("resumeNFT", new PauseNFTEvent({ isPaused: (0, import_o1js12.Bool)(false), address }));
|
|
2371
2414
|
}
|
|
2372
2415
|
/**
|
|
2373
2416
|
* Resumes a specific NFT, re-enabling its actions.
|
|
@@ -2381,7 +2424,7 @@ function CollectionFactory(params) {
|
|
|
2381
2424
|
const ownerContract2 = this.getOwnerContract(owner);
|
|
2382
2425
|
const canResume = await ownerContract2.canResume(this.address, address);
|
|
2383
2426
|
canResume.assertTrue();
|
|
2384
|
-
this.emitEvent("resumeNFT", new PauseNFTEvent({ isPaused: (0,
|
|
2427
|
+
this.emitEvent("resumeNFT", new PauseNFTEvent({ isPaused: (0, import_o1js12.Bool)(false), address }));
|
|
2385
2428
|
}
|
|
2386
2429
|
/**
|
|
2387
2430
|
* Sets a new name for the collection.
|
|
@@ -2442,7 +2485,7 @@ function CollectionFactory(params) {
|
|
|
2442
2485
|
async setRoyaltyFee(royaltyFee) {
|
|
2443
2486
|
const collectionData = CollectionData.unpack(this.packedData.getAndRequireEquals());
|
|
2444
2487
|
collectionData.isPaused.assertFalse(CollectionErrors.collectionPaused);
|
|
2445
|
-
royaltyFee.assertLessThanOrEqual(
|
|
2488
|
+
royaltyFee.assertLessThanOrEqual(import_o1js12.UInt32.from(MAX_ROYALTY_FEE), CollectionErrors.invalidRoyaltyFee);
|
|
2446
2489
|
const adminContract2 = this.getAdminContract();
|
|
2447
2490
|
const canChangeRoyalty = await adminContract2.canChangeRoyalty(royaltyFee);
|
|
2448
2491
|
canChangeRoyalty.assertTrue(CollectionErrors.noPermissionToChangeRoyalty);
|
|
@@ -2496,209 +2539,209 @@ function CollectionFactory(params) {
|
|
|
2496
2539
|
}
|
|
2497
2540
|
}
|
|
2498
2541
|
(0, import_tslib6.__decorate)([
|
|
2499
|
-
(0,
|
|
2542
|
+
(0, import_o1js12.state)(import_o1js12.Field),
|
|
2500
2543
|
(0, import_tslib6.__metadata)("design:type", Object)
|
|
2501
2544
|
], Collection2.prototype, "collectionName", void 0);
|
|
2502
2545
|
(0, import_tslib6.__decorate)([
|
|
2503
|
-
(0,
|
|
2546
|
+
(0, import_o1js12.state)(import_o1js12.PublicKey),
|
|
2504
2547
|
(0, import_tslib6.__metadata)("design:type", Object)
|
|
2505
2548
|
], Collection2.prototype, "creator", void 0);
|
|
2506
2549
|
(0, import_tslib6.__decorate)([
|
|
2507
|
-
(0,
|
|
2550
|
+
(0, import_o1js12.state)(import_o1js12.PublicKey),
|
|
2508
2551
|
(0, import_tslib6.__metadata)("design:type", Object)
|
|
2509
2552
|
], Collection2.prototype, "admin", void 0);
|
|
2510
2553
|
(0, import_tslib6.__decorate)([
|
|
2511
|
-
(0,
|
|
2554
|
+
(0, import_o1js12.state)(import_o1js12.Field),
|
|
2512
2555
|
(0, import_tslib6.__metadata)("design:type", Object)
|
|
2513
2556
|
], Collection2.prototype, "baseURL", void 0);
|
|
2514
2557
|
(0, import_tslib6.__decorate)([
|
|
2515
|
-
(0,
|
|
2558
|
+
(0, import_o1js12.state)(import_o1js12.Field),
|
|
2516
2559
|
(0, import_tslib6.__metadata)("design:type", Object)
|
|
2517
2560
|
], Collection2.prototype, "packedData", void 0);
|
|
2518
2561
|
(0, import_tslib6.__decorate)([
|
|
2519
|
-
|
|
2562
|
+
import_o1js12.method,
|
|
2520
2563
|
(0, import_tslib6.__metadata)("design:type", Function),
|
|
2521
2564
|
(0, import_tslib6.__metadata)("design:paramtypes", [MintParams, CollectionData]),
|
|
2522
2565
|
(0, import_tslib6.__metadata)("design:returntype", Promise)
|
|
2523
2566
|
], Collection2.prototype, "initialize", null);
|
|
2524
2567
|
(0, import_tslib6.__decorate)([
|
|
2525
|
-
|
|
2568
|
+
import_o1js12.method,
|
|
2526
2569
|
(0, import_tslib6.__metadata)("design:type", Function),
|
|
2527
2570
|
(0, import_tslib6.__metadata)("design:paramtypes", [MintParams]),
|
|
2528
2571
|
(0, import_tslib6.__metadata)("design:returntype", Promise)
|
|
2529
2572
|
], Collection2.prototype, "mintByCreator", null);
|
|
2530
2573
|
(0, import_tslib6.__decorate)([
|
|
2531
|
-
|
|
2574
|
+
import_o1js12.method,
|
|
2532
2575
|
(0, import_tslib6.__metadata)("design:type", Function),
|
|
2533
2576
|
(0, import_tslib6.__metadata)("design:paramtypes", [MintRequest]),
|
|
2534
2577
|
(0, import_tslib6.__metadata)("design:returntype", Promise)
|
|
2535
2578
|
], Collection2.prototype, "mint", null);
|
|
2536
2579
|
(0, import_tslib6.__decorate)([
|
|
2537
|
-
|
|
2580
|
+
import_o1js12.method,
|
|
2538
2581
|
(0, import_tslib6.__metadata)("design:type", Function),
|
|
2539
2582
|
(0, import_tslib6.__metadata)("design:paramtypes", [
|
|
2540
2583
|
NFTUpdateProof,
|
|
2541
|
-
|
|
2584
|
+
import_o1js12.VerificationKey
|
|
2542
2585
|
]),
|
|
2543
2586
|
(0, import_tslib6.__metadata)("design:returntype", Promise)
|
|
2544
2587
|
], Collection2.prototype, "update", null);
|
|
2545
2588
|
(0, import_tslib6.__decorate)([
|
|
2546
|
-
|
|
2589
|
+
import_o1js12.method,
|
|
2547
2590
|
(0, import_tslib6.__metadata)("design:type", Function),
|
|
2548
2591
|
(0, import_tslib6.__metadata)("design:paramtypes", [
|
|
2549
2592
|
NFTUpdateProof,
|
|
2550
|
-
|
|
2593
|
+
import_o1js12.VerificationKey
|
|
2551
2594
|
]),
|
|
2552
2595
|
(0, import_tslib6.__metadata)("design:returntype", Promise)
|
|
2553
2596
|
], Collection2.prototype, "updateWithOracle", null);
|
|
2554
2597
|
(0, import_tslib6.__decorate)([
|
|
2555
|
-
|
|
2598
|
+
import_o1js12.method,
|
|
2556
2599
|
(0, import_tslib6.__metadata)("design:type", Function),
|
|
2557
2600
|
(0, import_tslib6.__metadata)("design:paramtypes", [
|
|
2558
|
-
|
|
2559
|
-
|
|
2601
|
+
import_o1js12.PublicKey,
|
|
2602
|
+
import_o1js12.PublicKey
|
|
2560
2603
|
]),
|
|
2561
2604
|
(0, import_tslib6.__metadata)("design:returntype", Promise)
|
|
2562
2605
|
], Collection2.prototype, "approveAddress", null);
|
|
2563
2606
|
(0, import_tslib6.__decorate)([
|
|
2564
|
-
|
|
2607
|
+
import_o1js12.method,
|
|
2565
2608
|
(0, import_tslib6.__metadata)("design:type", Function),
|
|
2566
2609
|
(0, import_tslib6.__metadata)("design:paramtypes", [
|
|
2567
|
-
|
|
2568
|
-
|
|
2610
|
+
import_o1js12.PublicKey,
|
|
2611
|
+
import_o1js12.PublicKey
|
|
2569
2612
|
]),
|
|
2570
2613
|
(0, import_tslib6.__metadata)("design:returntype", Promise)
|
|
2571
2614
|
], Collection2.prototype, "approveAddressByProof", null);
|
|
2572
2615
|
(0, import_tslib6.__decorate)([
|
|
2573
|
-
|
|
2616
|
+
import_o1js12.method,
|
|
2574
2617
|
(0, import_tslib6.__metadata)("design:type", Function),
|
|
2575
2618
|
(0, import_tslib6.__metadata)("design:paramtypes", [TransferParams]),
|
|
2576
2619
|
(0, import_tslib6.__metadata)("design:returntype", Promise)
|
|
2577
2620
|
], Collection2.prototype, "transferBySignature", null);
|
|
2578
2621
|
(0, import_tslib6.__decorate)([
|
|
2579
|
-
|
|
2622
|
+
import_o1js12.method,
|
|
2580
2623
|
(0, import_tslib6.__metadata)("design:type", Function),
|
|
2581
2624
|
(0, import_tslib6.__metadata)("design:paramtypes", [TransferParams]),
|
|
2582
2625
|
(0, import_tslib6.__metadata)("design:returntype", Promise)
|
|
2583
2626
|
], Collection2.prototype, "transferByProof", null);
|
|
2584
2627
|
(0, import_tslib6.__decorate)([
|
|
2585
|
-
|
|
2628
|
+
import_o1js12.method,
|
|
2586
2629
|
(0, import_tslib6.__metadata)("design:type", Function),
|
|
2587
2630
|
(0, import_tslib6.__metadata)("design:paramtypes", [TransferParams]),
|
|
2588
2631
|
(0, import_tslib6.__metadata)("design:returntype", Promise)
|
|
2589
2632
|
], Collection2.prototype, "approvedTransferByProof", null);
|
|
2590
2633
|
(0, import_tslib6.__decorate)([
|
|
2591
|
-
|
|
2634
|
+
import_o1js12.method,
|
|
2592
2635
|
(0, import_tslib6.__metadata)("design:type", Function),
|
|
2593
2636
|
(0, import_tslib6.__metadata)("design:paramtypes", [TransferParams]),
|
|
2594
2637
|
(0, import_tslib6.__metadata)("design:returntype", Promise)
|
|
2595
2638
|
], Collection2.prototype, "approvedTransferBySignature", null);
|
|
2596
2639
|
(0, import_tslib6.__decorate)([
|
|
2597
|
-
|
|
2640
|
+
import_o1js12.method,
|
|
2598
2641
|
(0, import_tslib6.__metadata)("design:type", Function),
|
|
2599
2642
|
(0, import_tslib6.__metadata)("design:paramtypes", [
|
|
2600
|
-
|
|
2601
|
-
|
|
2643
|
+
import_o1js12.PublicKey,
|
|
2644
|
+
import_o1js12.VerificationKey
|
|
2602
2645
|
]),
|
|
2603
2646
|
(0, import_tslib6.__metadata)("design:returntype", Promise)
|
|
2604
2647
|
], Collection2.prototype, "upgradeNFTVerificationKeyBySignature", null);
|
|
2605
2648
|
(0, import_tslib6.__decorate)([
|
|
2606
|
-
|
|
2649
|
+
import_o1js12.method,
|
|
2607
2650
|
(0, import_tslib6.__metadata)("design:type", Function),
|
|
2608
2651
|
(0, import_tslib6.__metadata)("design:paramtypes", [
|
|
2609
|
-
|
|
2610
|
-
|
|
2652
|
+
import_o1js12.PublicKey,
|
|
2653
|
+
import_o1js12.VerificationKey
|
|
2611
2654
|
]),
|
|
2612
2655
|
(0, import_tslib6.__metadata)("design:returntype", Promise)
|
|
2613
2656
|
], Collection2.prototype, "upgradeNFTVerificationKeyByProof", null);
|
|
2614
2657
|
(0, import_tslib6.__decorate)([
|
|
2615
|
-
|
|
2658
|
+
import_o1js12.method,
|
|
2616
2659
|
(0, import_tslib6.__metadata)("design:type", Function),
|
|
2617
|
-
(0, import_tslib6.__metadata)("design:paramtypes", [
|
|
2660
|
+
(0, import_tslib6.__metadata)("design:paramtypes", [import_o1js12.VerificationKey]),
|
|
2618
2661
|
(0, import_tslib6.__metadata)("design:returntype", Promise)
|
|
2619
2662
|
], Collection2.prototype, "upgradeVerificationKey", null);
|
|
2620
2663
|
(0, import_tslib6.__decorate)([
|
|
2621
|
-
|
|
2664
|
+
import_o1js12.method,
|
|
2622
2665
|
(0, import_tslib6.__metadata)("design:type", Function),
|
|
2623
2666
|
(0, import_tslib6.__metadata)("design:paramtypes", []),
|
|
2624
2667
|
(0, import_tslib6.__metadata)("design:returntype", Promise)
|
|
2625
2668
|
], Collection2.prototype, "limitMinting", null);
|
|
2626
2669
|
(0, import_tslib6.__decorate)([
|
|
2627
|
-
|
|
2670
|
+
import_o1js12.method,
|
|
2628
2671
|
(0, import_tslib6.__metadata)("design:type", Function),
|
|
2629
2672
|
(0, import_tslib6.__metadata)("design:paramtypes", []),
|
|
2630
2673
|
(0, import_tslib6.__metadata)("design:returntype", Promise)
|
|
2631
2674
|
], Collection2.prototype, "pause", null);
|
|
2632
2675
|
(0, import_tslib6.__decorate)([
|
|
2633
|
-
|
|
2676
|
+
import_o1js12.method,
|
|
2634
2677
|
(0, import_tslib6.__metadata)("design:type", Function),
|
|
2635
2678
|
(0, import_tslib6.__metadata)("design:paramtypes", []),
|
|
2636
2679
|
(0, import_tslib6.__metadata)("design:returntype", Promise)
|
|
2637
2680
|
], Collection2.prototype, "resume", null);
|
|
2638
2681
|
(0, import_tslib6.__decorate)([
|
|
2639
|
-
|
|
2682
|
+
import_o1js12.method,
|
|
2640
2683
|
(0, import_tslib6.__metadata)("design:type", Function),
|
|
2641
|
-
(0, import_tslib6.__metadata)("design:paramtypes", [
|
|
2684
|
+
(0, import_tslib6.__metadata)("design:paramtypes", [import_o1js12.PublicKey]),
|
|
2642
2685
|
(0, import_tslib6.__metadata)("design:returntype", Promise)
|
|
2643
2686
|
], Collection2.prototype, "pauseNFTBySignature", null);
|
|
2644
2687
|
(0, import_tslib6.__decorate)([
|
|
2645
|
-
|
|
2688
|
+
import_o1js12.method,
|
|
2646
2689
|
(0, import_tslib6.__metadata)("design:type", Function),
|
|
2647
|
-
(0, import_tslib6.__metadata)("design:paramtypes", [
|
|
2690
|
+
(0, import_tslib6.__metadata)("design:paramtypes", [import_o1js12.PublicKey]),
|
|
2648
2691
|
(0, import_tslib6.__metadata)("design:returntype", Promise)
|
|
2649
2692
|
], Collection2.prototype, "pauseNFTByProof", null);
|
|
2650
2693
|
(0, import_tslib6.__decorate)([
|
|
2651
|
-
|
|
2694
|
+
import_o1js12.method,
|
|
2652
2695
|
(0, import_tslib6.__metadata)("design:type", Function),
|
|
2653
|
-
(0, import_tslib6.__metadata)("design:paramtypes", [
|
|
2696
|
+
(0, import_tslib6.__metadata)("design:paramtypes", [import_o1js12.PublicKey]),
|
|
2654
2697
|
(0, import_tslib6.__metadata)("design:returntype", Promise)
|
|
2655
2698
|
], Collection2.prototype, "resumeNFT", null);
|
|
2656
2699
|
(0, import_tslib6.__decorate)([
|
|
2657
|
-
|
|
2700
|
+
import_o1js12.method,
|
|
2658
2701
|
(0, import_tslib6.__metadata)("design:type", Function),
|
|
2659
|
-
(0, import_tslib6.__metadata)("design:paramtypes", [
|
|
2702
|
+
(0, import_tslib6.__metadata)("design:paramtypes", [import_o1js12.PublicKey]),
|
|
2660
2703
|
(0, import_tslib6.__metadata)("design:returntype", Promise)
|
|
2661
2704
|
], Collection2.prototype, "resumeNFTByProof", null);
|
|
2662
2705
|
(0, import_tslib6.__decorate)([
|
|
2663
|
-
|
|
2706
|
+
import_o1js12.method,
|
|
2664
2707
|
(0, import_tslib6.__metadata)("design:type", Function),
|
|
2665
|
-
(0, import_tslib6.__metadata)("design:paramtypes", [
|
|
2708
|
+
(0, import_tslib6.__metadata)("design:paramtypes", [import_o1js12.Field]),
|
|
2666
2709
|
(0, import_tslib6.__metadata)("design:returntype", Promise)
|
|
2667
2710
|
], Collection2.prototype, "setName", null);
|
|
2668
2711
|
(0, import_tslib6.__decorate)([
|
|
2669
|
-
|
|
2712
|
+
import_o1js12.method,
|
|
2670
2713
|
(0, import_tslib6.__metadata)("design:type", Function),
|
|
2671
|
-
(0, import_tslib6.__metadata)("design:paramtypes", [
|
|
2714
|
+
(0, import_tslib6.__metadata)("design:paramtypes", [import_o1js12.Field]),
|
|
2672
2715
|
(0, import_tslib6.__metadata)("design:returntype", Promise)
|
|
2673
2716
|
], Collection2.prototype, "setBaseURL", null);
|
|
2674
2717
|
(0, import_tslib6.__decorate)([
|
|
2675
|
-
|
|
2718
|
+
import_o1js12.method,
|
|
2676
2719
|
(0, import_tslib6.__metadata)("design:type", Function),
|
|
2677
|
-
(0, import_tslib6.__metadata)("design:paramtypes", [
|
|
2720
|
+
(0, import_tslib6.__metadata)("design:paramtypes", [import_o1js12.PublicKey]),
|
|
2678
2721
|
(0, import_tslib6.__metadata)("design:returntype", Promise)
|
|
2679
2722
|
], Collection2.prototype, "setAdmin", null);
|
|
2680
2723
|
(0, import_tslib6.__decorate)([
|
|
2681
|
-
|
|
2724
|
+
import_o1js12.method,
|
|
2682
2725
|
(0, import_tslib6.__metadata)("design:type", Function),
|
|
2683
|
-
(0, import_tslib6.__metadata)("design:paramtypes", [
|
|
2726
|
+
(0, import_tslib6.__metadata)("design:paramtypes", [import_o1js12.UInt32]),
|
|
2684
2727
|
(0, import_tslib6.__metadata)("design:returntype", Promise)
|
|
2685
2728
|
], Collection2.prototype, "setRoyaltyFee", null);
|
|
2686
2729
|
(0, import_tslib6.__decorate)([
|
|
2687
|
-
|
|
2730
|
+
import_o1js12.method,
|
|
2688
2731
|
(0, import_tslib6.__metadata)("design:type", Function),
|
|
2689
|
-
(0, import_tslib6.__metadata)("design:paramtypes", [
|
|
2732
|
+
(0, import_tslib6.__metadata)("design:paramtypes", [import_o1js12.UInt64]),
|
|
2690
2733
|
(0, import_tslib6.__metadata)("design:returntype", Promise)
|
|
2691
2734
|
], Collection2.prototype, "setTransferFee", null);
|
|
2692
2735
|
(0, import_tslib6.__decorate)([
|
|
2693
|
-
|
|
2736
|
+
import_o1js12.method.returns(import_o1js12.PublicKey),
|
|
2694
2737
|
(0, import_tslib6.__metadata)("design:type", Function),
|
|
2695
|
-
(0, import_tslib6.__metadata)("design:paramtypes", [
|
|
2738
|
+
(0, import_tslib6.__metadata)("design:paramtypes", [import_o1js12.PublicKey]),
|
|
2696
2739
|
(0, import_tslib6.__metadata)("design:returntype", Promise)
|
|
2697
2740
|
], Collection2.prototype, "transferOwnership", null);
|
|
2698
2741
|
(0, import_tslib6.__decorate)([
|
|
2699
|
-
|
|
2742
|
+
import_o1js12.method.returns(NFTStateStruct),
|
|
2700
2743
|
(0, import_tslib6.__metadata)("design:type", Function),
|
|
2701
|
-
(0, import_tslib6.__metadata)("design:paramtypes", [
|
|
2744
|
+
(0, import_tslib6.__metadata)("design:paramtypes", [import_o1js12.PublicKey]),
|
|
2702
2745
|
(0, import_tslib6.__metadata)("design:returntype", Promise)
|
|
2703
2746
|
], Collection2.prototype, "getNFTState", null);
|
|
2704
2747
|
return Collection2;
|
|
@@ -2706,18 +2749,18 @@ function CollectionFactory(params) {
|
|
|
2706
2749
|
|
|
2707
2750
|
// dist/node/contracts/admin.js
|
|
2708
2751
|
var import_tslib7 = require("tslib");
|
|
2709
|
-
var
|
|
2710
|
-
var NFTAdmin = class extends
|
|
2752
|
+
var import_o1js13 = require("o1js");
|
|
2753
|
+
var NFTAdmin = class extends import_o1js13.SmartContract {
|
|
2711
2754
|
constructor() {
|
|
2712
2755
|
super(...arguments);
|
|
2713
|
-
this.admin = (0,
|
|
2714
|
-
this.isPaused = (0,
|
|
2715
|
-
this.canBePaused = (0,
|
|
2716
|
-
this.allowChangeRoyalty = (0,
|
|
2717
|
-
this.allowChangeTransferFee = (0,
|
|
2756
|
+
this.admin = (0, import_o1js13.State)();
|
|
2757
|
+
this.isPaused = (0, import_o1js13.State)();
|
|
2758
|
+
this.canBePaused = (0, import_o1js13.State)();
|
|
2759
|
+
this.allowChangeRoyalty = (0, import_o1js13.State)();
|
|
2760
|
+
this.allowChangeTransferFee = (0, import_o1js13.State)();
|
|
2718
2761
|
this.events = {
|
|
2719
2762
|
/** Emitted when the verification key is upgraded. */
|
|
2720
|
-
upgradeVerificationKey:
|
|
2763
|
+
upgradeVerificationKey: import_o1js13.Field,
|
|
2721
2764
|
/** Emitted when the contract is paused. */
|
|
2722
2765
|
pause: PauseEvent,
|
|
2723
2766
|
/** Emitted when the contract is resumed. */
|
|
@@ -2733,21 +2776,21 @@ var NFTAdmin = class extends import_o1js12.SmartContract {
|
|
|
2733
2776
|
async deploy(props) {
|
|
2734
2777
|
await super.deploy(props);
|
|
2735
2778
|
this.admin.set(props.admin);
|
|
2736
|
-
this.isPaused.set(props.isPaused ?? (0,
|
|
2737
|
-
this.canBePaused.set(props.canBePaused ?? (0,
|
|
2738
|
-
this.allowChangeRoyalty.set(props.allowChangeRoyalty ?? (0,
|
|
2739
|
-
this.allowChangeTransferFee.set(props.allowChangeTransferFee ?? (0,
|
|
2779
|
+
this.isPaused.set(props.isPaused ?? (0, import_o1js13.Bool)(false));
|
|
2780
|
+
this.canBePaused.set(props.canBePaused ?? (0, import_o1js13.Bool)(true));
|
|
2781
|
+
this.allowChangeRoyalty.set(props.allowChangeRoyalty ?? (0, import_o1js13.Bool)(false));
|
|
2782
|
+
this.allowChangeTransferFee.set(props.allowChangeTransferFee ?? (0, import_o1js13.Bool)(false));
|
|
2740
2783
|
this.account.zkappUri.set(props.uri);
|
|
2741
2784
|
this.account.permissions.set({
|
|
2742
|
-
...
|
|
2785
|
+
...import_o1js13.Permissions.default(),
|
|
2743
2786
|
// Allow the upgrade authority to set the verification key
|
|
2744
2787
|
// even when there is no protocol upgrade
|
|
2745
|
-
setVerificationKey:
|
|
2746
|
-
setPermissions:
|
|
2747
|
-
access:
|
|
2748
|
-
send:
|
|
2749
|
-
setZkappUri:
|
|
2750
|
-
setTokenSymbol:
|
|
2788
|
+
setVerificationKey: import_o1js13.Permissions.VerificationKey.proofDuringCurrentVersion(),
|
|
2789
|
+
setPermissions: import_o1js13.Permissions.impossible(),
|
|
2790
|
+
access: import_o1js13.Permissions.proof(),
|
|
2791
|
+
send: import_o1js13.Permissions.proof(),
|
|
2792
|
+
setZkappUri: import_o1js13.Permissions.none(),
|
|
2793
|
+
setTokenSymbol: import_o1js13.Permissions.none()
|
|
2751
2794
|
});
|
|
2752
2795
|
}
|
|
2753
2796
|
/**
|
|
@@ -2756,8 +2799,8 @@ var NFTAdmin = class extends import_o1js12.SmartContract {
|
|
|
2756
2799
|
*/
|
|
2757
2800
|
async ensureOwnerSignature() {
|
|
2758
2801
|
const admin = this.admin.getAndRequireEquals();
|
|
2759
|
-
const adminUpdate =
|
|
2760
|
-
adminUpdate.body.useFullCommitment = (0,
|
|
2802
|
+
const adminUpdate = import_o1js13.AccountUpdate.createSigned(admin);
|
|
2803
|
+
adminUpdate.body.useFullCommitment = (0, import_o1js13.Bool)(true);
|
|
2761
2804
|
return adminUpdate;
|
|
2762
2805
|
}
|
|
2763
2806
|
/**
|
|
@@ -2786,7 +2829,7 @@ var NFTAdmin = class extends import_o1js12.SmartContract {
|
|
|
2786
2829
|
* @returns A `Bool` indicating whether the update is allowed.
|
|
2787
2830
|
*/
|
|
2788
2831
|
async canUpdate(input, output) {
|
|
2789
|
-
return (0,
|
|
2832
|
+
return (0, import_o1js13.Bool)(true);
|
|
2790
2833
|
}
|
|
2791
2834
|
/**
|
|
2792
2835
|
* Determines whether a transfer between the specified addresses is permitted.
|
|
@@ -2794,7 +2837,7 @@ var NFTAdmin = class extends import_o1js12.SmartContract {
|
|
|
2794
2837
|
* @returns A `Bool` indicating whether the transfer is allowed.
|
|
2795
2838
|
*/
|
|
2796
2839
|
async canTransfer(transferEvent) {
|
|
2797
|
-
return (0,
|
|
2840
|
+
return (0, import_o1js13.Bool)(true);
|
|
2798
2841
|
}
|
|
2799
2842
|
/**
|
|
2800
2843
|
* Pauses the contract, disabling certain administrative actions.
|
|
@@ -2803,8 +2846,8 @@ var NFTAdmin = class extends import_o1js12.SmartContract {
|
|
|
2803
2846
|
async pause() {
|
|
2804
2847
|
await this.ensureOwnerSignature();
|
|
2805
2848
|
this.canBePaused.getAndRequireEquals().assertTrue();
|
|
2806
|
-
this.isPaused.set((0,
|
|
2807
|
-
this.emitEvent("pause", new PauseEvent({ isPaused: (0,
|
|
2849
|
+
this.isPaused.set((0, import_o1js13.Bool)(true));
|
|
2850
|
+
this.emitEvent("pause", new PauseEvent({ isPaused: (0, import_o1js13.Bool)(true) }));
|
|
2808
2851
|
}
|
|
2809
2852
|
/**
|
|
2810
2853
|
* Resumes the contract, re-enabling administrative actions.
|
|
@@ -2813,8 +2856,8 @@ var NFTAdmin = class extends import_o1js12.SmartContract {
|
|
|
2813
2856
|
async resume() {
|
|
2814
2857
|
await this.ensureOwnerSignature();
|
|
2815
2858
|
this.canBePaused.getAndRequireEquals().assertTrue();
|
|
2816
|
-
this.isPaused.set((0,
|
|
2817
|
-
this.emitEvent("resume", new PauseEvent({ isPaused: (0,
|
|
2859
|
+
this.isPaused.set((0, import_o1js13.Bool)(false));
|
|
2860
|
+
this.emitEvent("resume", new PauseEvent({ isPaused: (0, import_o1js13.Bool)(false) }));
|
|
2818
2861
|
}
|
|
2819
2862
|
/**
|
|
2820
2863
|
* Transfers ownership of the contract to a new admin.
|
|
@@ -2835,25 +2878,25 @@ var NFTAdmin = class extends import_o1js12.SmartContract {
|
|
|
2835
2878
|
}
|
|
2836
2879
|
async canChangeVerificationKey(vk, address, tokenId) {
|
|
2837
2880
|
await this.ensureOwnerSignature();
|
|
2838
|
-
return (0,
|
|
2881
|
+
return (0, import_o1js13.Bool)(true);
|
|
2839
2882
|
}
|
|
2840
2883
|
/**
|
|
2841
2884
|
* Determines if the name can be changed for a Collection.
|
|
2842
2885
|
*/
|
|
2843
2886
|
async canChangeName(name) {
|
|
2844
|
-
return (0,
|
|
2887
|
+
return (0, import_o1js13.Bool)(false);
|
|
2845
2888
|
}
|
|
2846
2889
|
/**
|
|
2847
2890
|
* Determines if the creator can be changed for a Collection.
|
|
2848
2891
|
*/
|
|
2849
2892
|
async canChangeCreator(creator) {
|
|
2850
|
-
return (0,
|
|
2893
|
+
return (0, import_o1js13.Bool)(false);
|
|
2851
2894
|
}
|
|
2852
2895
|
/**
|
|
2853
2896
|
* Determines if the base URI can be changed for a Collection.
|
|
2854
2897
|
*/
|
|
2855
2898
|
async canChangeBaseUri(baseUri) {
|
|
2856
|
-
return (0,
|
|
2899
|
+
return (0, import_o1js13.Bool)(false);
|
|
2857
2900
|
}
|
|
2858
2901
|
/**
|
|
2859
2902
|
* Determines if the royalty fee can be changed for a Collection.
|
|
@@ -2873,7 +2916,7 @@ var NFTAdmin = class extends import_o1js12.SmartContract {
|
|
|
2873
2916
|
* Determines if the admin contract can be changed for a Collection.
|
|
2874
2917
|
*/
|
|
2875
2918
|
async canSetAdmin(admin) {
|
|
2876
|
-
return (0,
|
|
2919
|
+
return (0, import_o1js13.Bool)(false);
|
|
2877
2920
|
}
|
|
2878
2921
|
/**
|
|
2879
2922
|
* Determines if the collection can be paused.
|
|
@@ -2891,131 +2934,131 @@ var NFTAdmin = class extends import_o1js12.SmartContract {
|
|
|
2891
2934
|
}
|
|
2892
2935
|
};
|
|
2893
2936
|
(0, import_tslib7.__decorate)([
|
|
2894
|
-
(0,
|
|
2937
|
+
(0, import_o1js13.state)(import_o1js13.PublicKey),
|
|
2895
2938
|
(0, import_tslib7.__metadata)("design:type", Object)
|
|
2896
2939
|
], NFTAdmin.prototype, "admin", void 0);
|
|
2897
2940
|
(0, import_tslib7.__decorate)([
|
|
2898
|
-
(0,
|
|
2941
|
+
(0, import_o1js13.state)(import_o1js13.Bool),
|
|
2899
2942
|
(0, import_tslib7.__metadata)("design:type", Object)
|
|
2900
2943
|
], NFTAdmin.prototype, "isPaused", void 0);
|
|
2901
2944
|
(0, import_tslib7.__decorate)([
|
|
2902
|
-
(0,
|
|
2945
|
+
(0, import_o1js13.state)(import_o1js13.Bool),
|
|
2903
2946
|
(0, import_tslib7.__metadata)("design:type", Object)
|
|
2904
2947
|
], NFTAdmin.prototype, "canBePaused", void 0);
|
|
2905
2948
|
(0, import_tslib7.__decorate)([
|
|
2906
|
-
(0,
|
|
2949
|
+
(0, import_o1js13.state)(import_o1js13.Bool),
|
|
2907
2950
|
(0, import_tslib7.__metadata)("design:type", Object)
|
|
2908
2951
|
], NFTAdmin.prototype, "allowChangeRoyalty", void 0);
|
|
2909
2952
|
(0, import_tslib7.__decorate)([
|
|
2910
|
-
(0,
|
|
2953
|
+
(0, import_o1js13.state)(import_o1js13.Bool),
|
|
2911
2954
|
(0, import_tslib7.__metadata)("design:type", Object)
|
|
2912
2955
|
], NFTAdmin.prototype, "allowChangeTransferFee", void 0);
|
|
2913
2956
|
(0, import_tslib7.__decorate)([
|
|
2914
|
-
|
|
2957
|
+
import_o1js13.method,
|
|
2915
2958
|
(0, import_tslib7.__metadata)("design:type", Function),
|
|
2916
|
-
(0, import_tslib7.__metadata)("design:paramtypes", [
|
|
2959
|
+
(0, import_tslib7.__metadata)("design:paramtypes", [import_o1js13.VerificationKey]),
|
|
2917
2960
|
(0, import_tslib7.__metadata)("design:returntype", Promise)
|
|
2918
2961
|
], NFTAdmin.prototype, "upgradeVerificationKey", null);
|
|
2919
2962
|
(0, import_tslib7.__decorate)([
|
|
2920
|
-
|
|
2963
|
+
import_o1js13.method.returns(MintParamsOption),
|
|
2921
2964
|
(0, import_tslib7.__metadata)("design:type", Function),
|
|
2922
2965
|
(0, import_tslib7.__metadata)("design:paramtypes", [MintRequest]),
|
|
2923
2966
|
(0, import_tslib7.__metadata)("design:returntype", Promise)
|
|
2924
2967
|
], NFTAdmin.prototype, "canMint", null);
|
|
2925
2968
|
(0, import_tslib7.__decorate)([
|
|
2926
|
-
|
|
2969
|
+
import_o1js13.method.returns(import_o1js13.Bool),
|
|
2927
2970
|
(0, import_tslib7.__metadata)("design:type", Function),
|
|
2928
2971
|
(0, import_tslib7.__metadata)("design:paramtypes", [NFTState, NFTState]),
|
|
2929
2972
|
(0, import_tslib7.__metadata)("design:returntype", Promise)
|
|
2930
2973
|
], NFTAdmin.prototype, "canUpdate", null);
|
|
2931
2974
|
(0, import_tslib7.__decorate)([
|
|
2932
|
-
|
|
2975
|
+
import_o1js13.method.returns(import_o1js13.Bool),
|
|
2933
2976
|
(0, import_tslib7.__metadata)("design:type", Function),
|
|
2934
2977
|
(0, import_tslib7.__metadata)("design:paramtypes", [TransferEvent]),
|
|
2935
2978
|
(0, import_tslib7.__metadata)("design:returntype", Promise)
|
|
2936
2979
|
], NFTAdmin.prototype, "canTransfer", null);
|
|
2937
2980
|
(0, import_tslib7.__decorate)([
|
|
2938
|
-
|
|
2981
|
+
import_o1js13.method,
|
|
2939
2982
|
(0, import_tslib7.__metadata)("design:type", Function),
|
|
2940
2983
|
(0, import_tslib7.__metadata)("design:paramtypes", []),
|
|
2941
2984
|
(0, import_tslib7.__metadata)("design:returntype", Promise)
|
|
2942
2985
|
], NFTAdmin.prototype, "pause", null);
|
|
2943
2986
|
(0, import_tslib7.__decorate)([
|
|
2944
|
-
|
|
2987
|
+
import_o1js13.method,
|
|
2945
2988
|
(0, import_tslib7.__metadata)("design:type", Function),
|
|
2946
2989
|
(0, import_tslib7.__metadata)("design:paramtypes", []),
|
|
2947
2990
|
(0, import_tslib7.__metadata)("design:returntype", Promise)
|
|
2948
2991
|
], NFTAdmin.prototype, "resume", null);
|
|
2949
2992
|
(0, import_tslib7.__decorate)([
|
|
2950
|
-
|
|
2993
|
+
import_o1js13.method.returns(import_o1js13.PublicKey),
|
|
2951
2994
|
(0, import_tslib7.__metadata)("design:type", Function),
|
|
2952
|
-
(0, import_tslib7.__metadata)("design:paramtypes", [
|
|
2995
|
+
(0, import_tslib7.__metadata)("design:paramtypes", [import_o1js13.PublicKey]),
|
|
2953
2996
|
(0, import_tslib7.__metadata)("design:returntype", Promise)
|
|
2954
2997
|
], NFTAdmin.prototype, "transferOwnership", null);
|
|
2955
2998
|
(0, import_tslib7.__decorate)([
|
|
2956
|
-
|
|
2999
|
+
import_o1js13.method.returns(import_o1js13.Bool),
|
|
2957
3000
|
(0, import_tslib7.__metadata)("design:type", Function),
|
|
2958
3001
|
(0, import_tslib7.__metadata)("design:paramtypes", [
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
3002
|
+
import_o1js13.VerificationKey,
|
|
3003
|
+
import_o1js13.PublicKey,
|
|
3004
|
+
import_o1js13.Field
|
|
2962
3005
|
]),
|
|
2963
3006
|
(0, import_tslib7.__metadata)("design:returntype", Promise)
|
|
2964
3007
|
], NFTAdmin.prototype, "canChangeVerificationKey", null);
|
|
2965
3008
|
(0, import_tslib7.__decorate)([
|
|
2966
|
-
|
|
3009
|
+
import_o1js13.method.returns(import_o1js13.Bool),
|
|
2967
3010
|
(0, import_tslib7.__metadata)("design:type", Function),
|
|
2968
|
-
(0, import_tslib7.__metadata)("design:paramtypes", [
|
|
3011
|
+
(0, import_tslib7.__metadata)("design:paramtypes", [import_o1js13.Field]),
|
|
2969
3012
|
(0, import_tslib7.__metadata)("design:returntype", Promise)
|
|
2970
3013
|
], NFTAdmin.prototype, "canChangeName", null);
|
|
2971
3014
|
(0, import_tslib7.__decorate)([
|
|
2972
|
-
|
|
3015
|
+
import_o1js13.method.returns(import_o1js13.Bool),
|
|
2973
3016
|
(0, import_tslib7.__metadata)("design:type", Function),
|
|
2974
|
-
(0, import_tslib7.__metadata)("design:paramtypes", [
|
|
3017
|
+
(0, import_tslib7.__metadata)("design:paramtypes", [import_o1js13.PublicKey]),
|
|
2975
3018
|
(0, import_tslib7.__metadata)("design:returntype", Promise)
|
|
2976
3019
|
], NFTAdmin.prototype, "canChangeCreator", null);
|
|
2977
3020
|
(0, import_tslib7.__decorate)([
|
|
2978
|
-
|
|
3021
|
+
import_o1js13.method.returns(import_o1js13.Bool),
|
|
2979
3022
|
(0, import_tslib7.__metadata)("design:type", Function),
|
|
2980
|
-
(0, import_tslib7.__metadata)("design:paramtypes", [
|
|
3023
|
+
(0, import_tslib7.__metadata)("design:paramtypes", [import_o1js13.Field]),
|
|
2981
3024
|
(0, import_tslib7.__metadata)("design:returntype", Promise)
|
|
2982
3025
|
], NFTAdmin.prototype, "canChangeBaseUri", null);
|
|
2983
3026
|
(0, import_tslib7.__decorate)([
|
|
2984
|
-
|
|
3027
|
+
import_o1js13.method.returns(import_o1js13.Bool),
|
|
2985
3028
|
(0, import_tslib7.__metadata)("design:type", Function),
|
|
2986
|
-
(0, import_tslib7.__metadata)("design:paramtypes", [
|
|
3029
|
+
(0, import_tslib7.__metadata)("design:paramtypes", [import_o1js13.UInt32]),
|
|
2987
3030
|
(0, import_tslib7.__metadata)("design:returntype", Promise)
|
|
2988
3031
|
], NFTAdmin.prototype, "canChangeRoyalty", null);
|
|
2989
3032
|
(0, import_tslib7.__decorate)([
|
|
2990
|
-
|
|
3033
|
+
import_o1js13.method.returns(import_o1js13.Bool),
|
|
2991
3034
|
(0, import_tslib7.__metadata)("design:type", Function),
|
|
2992
|
-
(0, import_tslib7.__metadata)("design:paramtypes", [
|
|
3035
|
+
(0, import_tslib7.__metadata)("design:paramtypes", [import_o1js13.UInt64]),
|
|
2993
3036
|
(0, import_tslib7.__metadata)("design:returntype", Promise)
|
|
2994
3037
|
], NFTAdmin.prototype, "canChangeTransferFee", null);
|
|
2995
3038
|
(0, import_tslib7.__decorate)([
|
|
2996
|
-
|
|
3039
|
+
import_o1js13.method.returns(import_o1js13.Bool),
|
|
2997
3040
|
(0, import_tslib7.__metadata)("design:type", Function),
|
|
2998
|
-
(0, import_tslib7.__metadata)("design:paramtypes", [
|
|
3041
|
+
(0, import_tslib7.__metadata)("design:paramtypes", [import_o1js13.PublicKey]),
|
|
2999
3042
|
(0, import_tslib7.__metadata)("design:returntype", Promise)
|
|
3000
3043
|
], NFTAdmin.prototype, "canSetAdmin", null);
|
|
3001
3044
|
(0, import_tslib7.__decorate)([
|
|
3002
|
-
|
|
3045
|
+
import_o1js13.method.returns(import_o1js13.Bool),
|
|
3003
3046
|
(0, import_tslib7.__metadata)("design:type", Function),
|
|
3004
3047
|
(0, import_tslib7.__metadata)("design:paramtypes", []),
|
|
3005
3048
|
(0, import_tslib7.__metadata)("design:returntype", Promise)
|
|
3006
3049
|
], NFTAdmin.prototype, "canPause", null);
|
|
3007
3050
|
(0, import_tslib7.__decorate)([
|
|
3008
|
-
|
|
3051
|
+
import_o1js13.method.returns(import_o1js13.Bool),
|
|
3009
3052
|
(0, import_tslib7.__metadata)("design:type", Function),
|
|
3010
3053
|
(0, import_tslib7.__metadata)("design:paramtypes", []),
|
|
3011
3054
|
(0, import_tslib7.__metadata)("design:returntype", Promise)
|
|
3012
3055
|
], NFTAdmin.prototype, "canResume", null);
|
|
3013
3056
|
|
|
3014
3057
|
// dist/node/metadata/metadata.js
|
|
3015
|
-
var
|
|
3058
|
+
var import_o1js17 = require("o1js");
|
|
3016
3059
|
|
|
3017
3060
|
// dist/node/metadata/text.js
|
|
3018
|
-
var
|
|
3061
|
+
var import_o1js14 = require("o1js");
|
|
3019
3062
|
var TEXT_TREE_HEIGHT = 20;
|
|
3020
3063
|
var Text = class {
|
|
3021
3064
|
/**
|
|
@@ -3029,11 +3072,11 @@ var Text = class {
|
|
|
3029
3072
|
constructor(text, height = TEXT_TREE_HEIGHT) {
|
|
3030
3073
|
this.text = text;
|
|
3031
3074
|
this.size = text.length;
|
|
3032
|
-
const tree = new
|
|
3075
|
+
const tree = new import_o1js14.MerkleTree(height);
|
|
3033
3076
|
if (this.size > tree.leafCount)
|
|
3034
3077
|
throw new Error(`Text is too long`);
|
|
3035
3078
|
for (let i = 0; i < this.size; i++) {
|
|
3036
|
-
tree.setLeaf(BigInt(i),
|
|
3079
|
+
tree.setLeaf(BigInt(i), import_o1js14.Field.from(this.text.charCodeAt(i)));
|
|
3037
3080
|
}
|
|
3038
3081
|
this.root = tree.getRoot();
|
|
3039
3082
|
this.height = height;
|
|
@@ -3048,8 +3091,40 @@ var Text = class {
|
|
|
3048
3091
|
}
|
|
3049
3092
|
};
|
|
3050
3093
|
|
|
3094
|
+
// dist/node/metadata/address.js
|
|
3095
|
+
var import_o1js15 = require("o1js");
|
|
3096
|
+
var MinaAddress = class {
|
|
3097
|
+
/**
|
|
3098
|
+
* Constructs a new `MinaAddress` instance by creating a Merkle tree from the given address.
|
|
3099
|
+
* The address is converted to its hash and stored as a leaf in the tree.
|
|
3100
|
+
*
|
|
3101
|
+
* @param address - The address to be represented.
|
|
3102
|
+
* @throws Will throw an error if the address is not a valid Mina address.
|
|
3103
|
+
*/
|
|
3104
|
+
constructor(address) {
|
|
3105
|
+
this.address = typeof address === "string" ? import_o1js15.PublicKey.fromBase58(address) : address;
|
|
3106
|
+
this.hash = import_o1js15.Poseidon.hashPacked(import_o1js15.PublicKey, this.address);
|
|
3107
|
+
}
|
|
3108
|
+
/**
|
|
3109
|
+
* Returns the original address.
|
|
3110
|
+
*
|
|
3111
|
+
* @returns The public key.
|
|
3112
|
+
*/
|
|
3113
|
+
toPublicKey() {
|
|
3114
|
+
return this.address;
|
|
3115
|
+
}
|
|
3116
|
+
/**
|
|
3117
|
+
* Returns the base58 representation of the address.
|
|
3118
|
+
*
|
|
3119
|
+
* @returns The base58 representation of the address.
|
|
3120
|
+
*/
|
|
3121
|
+
toString() {
|
|
3122
|
+
return this.address.toBase58();
|
|
3123
|
+
}
|
|
3124
|
+
};
|
|
3125
|
+
|
|
3051
3126
|
// dist/node/metadata/tree.js
|
|
3052
|
-
var
|
|
3127
|
+
var import_o1js16 = require("o1js");
|
|
3053
3128
|
var MetadataTree = class _MetadataTree {
|
|
3054
3129
|
/**
|
|
3055
3130
|
* Constructs a new `MetadataTree` with the specified height and key-value pairs.
|
|
@@ -3063,7 +3138,7 @@ var MetadataTree = class _MetadataTree {
|
|
|
3063
3138
|
constructor(height, values) {
|
|
3064
3139
|
this.values = values;
|
|
3065
3140
|
this.height = height;
|
|
3066
|
-
const tree = new
|
|
3141
|
+
const tree = new import_o1js16.MerkleTree(height);
|
|
3067
3142
|
const maxElements = tree.leafCount;
|
|
3068
3143
|
if (values.length > tree.leafCount) {
|
|
3069
3144
|
throw new Error(`Tree height ${height} can only have ${maxElements} elements`);
|
|
@@ -3104,7 +3179,7 @@ var MetadataTree = class _MetadataTree {
|
|
|
3104
3179
|
const { height, values, root } = json;
|
|
3105
3180
|
if (typeof height !== "number" || height < 1 || height > 254)
|
|
3106
3181
|
throw new Error(`Invalid tree height`);
|
|
3107
|
-
if (
|
|
3182
|
+
if (root && typeof root !== "string")
|
|
3108
3183
|
throw new Error(`Invalid tree root`);
|
|
3109
3184
|
if (!values || !Array.isArray(values))
|
|
3110
3185
|
throw new Error(`Tree values are required`);
|
|
@@ -3116,9 +3191,9 @@ var MetadataTree = class _MetadataTree {
|
|
|
3116
3191
|
}
|
|
3117
3192
|
const tree = new _MetadataTree(height, values.map(({ key, value }) => ({
|
|
3118
3193
|
key: BigInt(key),
|
|
3119
|
-
value:
|
|
3194
|
+
value: import_o1js16.Field.fromJSON(value)
|
|
3120
3195
|
})));
|
|
3121
|
-
if (tree.root.toJSON() !== root)
|
|
3196
|
+
if (root && tree.root.toJSON() !== root)
|
|
3122
3197
|
throw new Error("Invalid tree json");
|
|
3123
3198
|
return tree;
|
|
3124
3199
|
}
|
|
@@ -3126,14 +3201,14 @@ var MetadataTree = class _MetadataTree {
|
|
|
3126
3201
|
|
|
3127
3202
|
// dist/node/metadata/metadata.js
|
|
3128
3203
|
var METADATA_HEIGHT = 20;
|
|
3129
|
-
var IndexedMerkleMap =
|
|
3204
|
+
var IndexedMerkleMap = import_o1js17.Experimental.IndexedMerkleMap;
|
|
3130
3205
|
var MetadataMap = class extends IndexedMerkleMap(METADATA_HEIGHT) {
|
|
3131
3206
|
};
|
|
3132
|
-
var MetadataValue = class _MetadataValue extends (0,
|
|
3133
|
-
value:
|
|
3134
|
-
type:
|
|
3135
|
-
length:
|
|
3136
|
-
height:
|
|
3207
|
+
var MetadataValue = class _MetadataValue extends (0, import_o1js17.Struct)({
|
|
3208
|
+
value: import_o1js17.Field,
|
|
3209
|
+
type: import_o1js17.Field,
|
|
3210
|
+
length: import_o1js17.Field,
|
|
3211
|
+
height: import_o1js17.Field
|
|
3137
3212
|
}) {
|
|
3138
3213
|
/**
|
|
3139
3214
|
* Creates a new MetadataValue instance.
|
|
@@ -3143,11 +3218,11 @@ var MetadataValue = class _MetadataValue extends (0, import_o1js15.Struct)({
|
|
|
3143
3218
|
static new(params) {
|
|
3144
3219
|
const { value, type } = params;
|
|
3145
3220
|
let valueField;
|
|
3146
|
-
let length = (0,
|
|
3147
|
-
let height = (0,
|
|
3221
|
+
let length = (0, import_o1js17.Field)(0);
|
|
3222
|
+
let height = (0, import_o1js17.Field)(0);
|
|
3148
3223
|
switch (type) {
|
|
3149
3224
|
case "string":
|
|
3150
|
-
if (!(value instanceof
|
|
3225
|
+
if (!(value instanceof import_o1js17.Field))
|
|
3151
3226
|
throw new Error(`Invalid value type`);
|
|
3152
3227
|
valueField = value;
|
|
3153
3228
|
break;
|
|
@@ -3157,34 +3232,47 @@ var MetadataValue = class _MetadataValue extends (0, import_o1js15.Struct)({
|
|
|
3157
3232
|
if (!(value instanceof Text))
|
|
3158
3233
|
throw new Error(`Invalid value type`);
|
|
3159
3234
|
valueField = value.root;
|
|
3160
|
-
length = (0,
|
|
3161
|
-
height = (0,
|
|
3235
|
+
length = (0, import_o1js17.Field)(value.size);
|
|
3236
|
+
height = (0, import_o1js17.Field)(value.height);
|
|
3162
3237
|
break;
|
|
3163
3238
|
case "field":
|
|
3164
|
-
if (!(value instanceof
|
|
3239
|
+
if (!(value instanceof import_o1js17.Field))
|
|
3165
3240
|
throw new Error(`Invalid value type`);
|
|
3166
3241
|
valueField = value;
|
|
3167
3242
|
break;
|
|
3243
|
+
case "number":
|
|
3244
|
+
if (!(value instanceof import_o1js17.UInt64))
|
|
3245
|
+
throw new Error(`Invalid value type`);
|
|
3246
|
+
valueField = value.value;
|
|
3247
|
+
break;
|
|
3248
|
+
case "address":
|
|
3249
|
+
if (!(value instanceof import_o1js17.PublicKey))
|
|
3250
|
+
throw new Error(`Invalid value type`);
|
|
3251
|
+
const address = new MinaAddress(value);
|
|
3252
|
+
valueField = address.hash;
|
|
3253
|
+
length = (0, import_o1js17.Field)(2);
|
|
3254
|
+
height = (0, import_o1js17.Field)(0);
|
|
3255
|
+
break;
|
|
3168
3256
|
case "map":
|
|
3169
3257
|
if (!(value instanceof Metadata))
|
|
3170
3258
|
throw new Error(`Invalid value type`);
|
|
3171
3259
|
valueField = value.map.root;
|
|
3172
|
-
length = (0,
|
|
3173
|
-
height = (0,
|
|
3260
|
+
length = (0, import_o1js17.Field)(value.map.length);
|
|
3261
|
+
height = (0, import_o1js17.Field)(value.map.height);
|
|
3174
3262
|
break;
|
|
3175
3263
|
case "tree":
|
|
3176
3264
|
if (!(value instanceof MetadataTree))
|
|
3177
3265
|
throw new Error(`Invalid value type`);
|
|
3178
3266
|
valueField = value.root;
|
|
3179
|
-
length = (0,
|
|
3180
|
-
height = (0,
|
|
3267
|
+
length = (0, import_o1js17.Field)(value.values.length);
|
|
3268
|
+
height = (0, import_o1js17.Field)(value.height);
|
|
3181
3269
|
break;
|
|
3182
3270
|
default:
|
|
3183
3271
|
throw new Error(`Unknown value type`);
|
|
3184
3272
|
}
|
|
3185
3273
|
return new _MetadataValue({
|
|
3186
3274
|
value: valueField,
|
|
3187
|
-
type: (0,
|
|
3275
|
+
type: (0, import_o1js17.Field)(MetadataFieldTypeValues[type].code),
|
|
3188
3276
|
length,
|
|
3189
3277
|
height
|
|
3190
3278
|
});
|
|
@@ -3194,7 +3282,7 @@ var MetadataValue = class _MetadataValue extends (0, import_o1js15.Struct)({
|
|
|
3194
3282
|
* @returns The hash as a Field.
|
|
3195
3283
|
*/
|
|
3196
3284
|
hash() {
|
|
3197
|
-
return
|
|
3285
|
+
return import_o1js17.Poseidon.hash(_MetadataValue.toFields(this));
|
|
3198
3286
|
}
|
|
3199
3287
|
};
|
|
3200
3288
|
var MetadataPlugin = class {
|
|
@@ -3243,10 +3331,10 @@ var ColorPlugin = class extends MetadataPlugin {
|
|
|
3243
3331
|
return {
|
|
3244
3332
|
key: fieldFromString(key),
|
|
3245
3333
|
value: new MetadataValue({
|
|
3246
|
-
value: (0,
|
|
3247
|
-
type: (0,
|
|
3248
|
-
length: (0,
|
|
3249
|
-
height: (0,
|
|
3334
|
+
value: (0, import_o1js17.Field)(color),
|
|
3335
|
+
type: (0, import_o1js17.Field)(10),
|
|
3336
|
+
length: (0, import_o1js17.Field)(0),
|
|
3337
|
+
height: (0, import_o1js17.Field)(0)
|
|
3250
3338
|
}),
|
|
3251
3339
|
canonicalRepresentation: color
|
|
3252
3340
|
};
|
|
@@ -3335,9 +3423,19 @@ var Metadata = class _Metadata {
|
|
|
3335
3423
|
valueObject = new Text(value);
|
|
3336
3424
|
break;
|
|
3337
3425
|
case "field":
|
|
3338
|
-
if (!(value instanceof
|
|
3426
|
+
if (!(value instanceof import_o1js17.Field || typeof value === "bigint" || typeof value === "number" || typeof value === "string"))
|
|
3339
3427
|
throw new Error(`Invalid trait value type`);
|
|
3340
|
-
valueObject = value;
|
|
3428
|
+
valueObject = (0, import_o1js17.Field)(value);
|
|
3429
|
+
break;
|
|
3430
|
+
case "number":
|
|
3431
|
+
if (!(value instanceof import_o1js17.UInt64 || typeof value === "bigint" || typeof value === "number" || typeof value === "string"))
|
|
3432
|
+
throw new Error(`Invalid trait value type`);
|
|
3433
|
+
valueObject = import_o1js17.UInt64.from(value);
|
|
3434
|
+
break;
|
|
3435
|
+
case "address":
|
|
3436
|
+
if (!(value instanceof import_o1js17.PublicKey || typeof value === "string"))
|
|
3437
|
+
throw new Error(`Invalid trait value type`);
|
|
3438
|
+
valueObject = typeof value === "string" ? import_o1js17.PublicKey.fromBase58(value) : value;
|
|
3341
3439
|
break;
|
|
3342
3440
|
case "map":
|
|
3343
3441
|
if (!(value instanceof _Metadata))
|
|
@@ -3392,10 +3490,20 @@ var Metadata = class _Metadata {
|
|
|
3392
3490
|
jsonValue = value;
|
|
3393
3491
|
break;
|
|
3394
3492
|
case "field":
|
|
3395
|
-
if (!(value instanceof
|
|
3493
|
+
if (!(value instanceof import_o1js17.Field))
|
|
3494
|
+
throw new Error(`Invalid trait value type`);
|
|
3495
|
+
jsonValue = value.toJSON();
|
|
3496
|
+
break;
|
|
3497
|
+
case "number":
|
|
3498
|
+
if (!(value instanceof import_o1js17.UInt64))
|
|
3396
3499
|
throw new Error(`Invalid trait value type`);
|
|
3397
3500
|
jsonValue = value.toJSON();
|
|
3398
3501
|
break;
|
|
3502
|
+
case "address":
|
|
3503
|
+
if (!(value instanceof import_o1js17.PublicKey))
|
|
3504
|
+
throw new Error(`Invalid trait value type`);
|
|
3505
|
+
jsonValue = value.toBase58();
|
|
3506
|
+
break;
|
|
3399
3507
|
case "map":
|
|
3400
3508
|
if (!(value instanceof _Metadata))
|
|
3401
3509
|
throw new Error(`Invalid trait value type`);
|
|
@@ -3428,7 +3536,7 @@ var Metadata = class _Metadata {
|
|
|
3428
3536
|
*/
|
|
3429
3537
|
static fromJSON(params) {
|
|
3430
3538
|
const { json, checkRoot = false, plugins } = params;
|
|
3431
|
-
const { name, description, image, banner, metadataRoot, traits } = json;
|
|
3539
|
+
const { name, description, image, banner, metadataRoot, traits = [] } = json;
|
|
3432
3540
|
if (!name)
|
|
3433
3541
|
throw new Error(`Metadata name is required`);
|
|
3434
3542
|
if (typeof name !== "string")
|
|
@@ -3474,7 +3582,17 @@ var Metadata = class _Metadata {
|
|
|
3474
3582
|
case "field":
|
|
3475
3583
|
if (typeof value !== "string")
|
|
3476
3584
|
throw new Error(`Invalid trait value type`);
|
|
3477
|
-
valueField =
|
|
3585
|
+
valueField = import_o1js17.Field.fromJSON(value);
|
|
3586
|
+
break;
|
|
3587
|
+
case "number":
|
|
3588
|
+
if (typeof value !== "string")
|
|
3589
|
+
throw new Error(`Invalid trait value type`);
|
|
3590
|
+
valueField = import_o1js17.UInt64.fromJSON(value);
|
|
3591
|
+
break;
|
|
3592
|
+
case "address":
|
|
3593
|
+
if (typeof value !== "string")
|
|
3594
|
+
throw new Error(`Invalid trait value type`);
|
|
3595
|
+
valueField = import_o1js17.PublicKey.fromBase58(value);
|
|
3478
3596
|
break;
|
|
3479
3597
|
case "map":
|
|
3480
3598
|
if (typeof value !== "object")
|
|
@@ -3512,9 +3630,99 @@ var Metadata = class _Metadata {
|
|
|
3512
3630
|
}
|
|
3513
3631
|
return metadata;
|
|
3514
3632
|
}
|
|
3633
|
+
/**
|
|
3634
|
+
* Constructs a Metadata instance from OpenAPI JSON data (without calculated root).
|
|
3635
|
+
* @param params - The parameters including json data, checkRoot flag, and plugins.
|
|
3636
|
+
* @returns A new Metadata instance.
|
|
3637
|
+
*/
|
|
3638
|
+
static fromOpenApiJSON(params) {
|
|
3639
|
+
const { json, plugins } = params;
|
|
3640
|
+
const { name, description, image, banner, traits = [] } = json;
|
|
3641
|
+
if (!name)
|
|
3642
|
+
throw new Error(`Metadata name is required`);
|
|
3643
|
+
if (typeof name !== "string")
|
|
3644
|
+
throw new Error(`Invalid metadata name`);
|
|
3645
|
+
if (!image || typeof image !== "string")
|
|
3646
|
+
throw new Error(`Invalid metadata image`);
|
|
3647
|
+
if (description && typeof description !== "string")
|
|
3648
|
+
throw new Error(`Invalid metadata description`);
|
|
3649
|
+
if (banner && typeof banner !== "string")
|
|
3650
|
+
throw new Error(`Invalid metadata banner`);
|
|
3651
|
+
if (!traits || !Array.isArray(traits))
|
|
3652
|
+
throw new Error(`Metadata traits are required`);
|
|
3653
|
+
for (const { key, type, value, isPrivate } of traits) {
|
|
3654
|
+
if (!key || typeof key !== "string")
|
|
3655
|
+
throw new Error(`Invalid trait key`);
|
|
3656
|
+
if (!type || typeof type !== "string")
|
|
3657
|
+
throw new Error(`Invalid trait type`);
|
|
3658
|
+
if (!value || typeof value !== "string" && typeof value !== "object")
|
|
3659
|
+
throw new Error(`Invalid trait value`);
|
|
3660
|
+
if (isPrivate && typeof isPrivate !== "boolean")
|
|
3661
|
+
throw new Error(`Invalid trait isPrivate`);
|
|
3662
|
+
}
|
|
3663
|
+
const metadata = new _Metadata({
|
|
3664
|
+
name,
|
|
3665
|
+
description,
|
|
3666
|
+
image,
|
|
3667
|
+
banner,
|
|
3668
|
+
plugins
|
|
3669
|
+
});
|
|
3670
|
+
for (const { key, type, value, isPrivate } of traits) {
|
|
3671
|
+
let valueField;
|
|
3672
|
+
switch (type) {
|
|
3673
|
+
case "string":
|
|
3674
|
+
case "text":
|
|
3675
|
+
case "image":
|
|
3676
|
+
case "url":
|
|
3677
|
+
if (typeof value !== "string")
|
|
3678
|
+
throw new Error(`Invalid trait value type`);
|
|
3679
|
+
valueField = value;
|
|
3680
|
+
break;
|
|
3681
|
+
case "field":
|
|
3682
|
+
if (typeof value !== "string")
|
|
3683
|
+
throw new Error(`Invalid trait value type`);
|
|
3684
|
+
valueField = import_o1js17.Field.fromJSON(value);
|
|
3685
|
+
break;
|
|
3686
|
+
case "number":
|
|
3687
|
+
if (typeof value !== "string")
|
|
3688
|
+
throw new Error(`Invalid trait value type`);
|
|
3689
|
+
valueField = import_o1js17.UInt64.fromJSON(value);
|
|
3690
|
+
break;
|
|
3691
|
+
case "address":
|
|
3692
|
+
if (typeof value !== "string")
|
|
3693
|
+
throw new Error(`Invalid trait value type`);
|
|
3694
|
+
valueField = import_o1js17.PublicKey.fromBase58(value);
|
|
3695
|
+
break;
|
|
3696
|
+
case "map":
|
|
3697
|
+
if (typeof value !== "object")
|
|
3698
|
+
throw new Error(`Invalid trait value type`);
|
|
3699
|
+
valueField = _Metadata.fromOpenApiJSON({
|
|
3700
|
+
json: value
|
|
3701
|
+
});
|
|
3702
|
+
break;
|
|
3703
|
+
case "tree":
|
|
3704
|
+
if (typeof value !== "object")
|
|
3705
|
+
throw new Error(`Invalid trait value type`);
|
|
3706
|
+
valueField = MetadataTree.fromJSON(value);
|
|
3707
|
+
break;
|
|
3708
|
+
default:
|
|
3709
|
+
const plugin = metadata.plugins.find((plugin2) => plugin2.name === type);
|
|
3710
|
+
if (!plugin)
|
|
3711
|
+
throw new Error(`Unknown trait type`);
|
|
3712
|
+
valueField = plugin.fromJSON(value);
|
|
3713
|
+
}
|
|
3714
|
+
metadata.addTrait({
|
|
3715
|
+
key,
|
|
3716
|
+
type,
|
|
3717
|
+
value: valueField,
|
|
3718
|
+
isPrivate: isPrivate ?? false
|
|
3719
|
+
});
|
|
3720
|
+
}
|
|
3721
|
+
return metadata;
|
|
3722
|
+
}
|
|
3515
3723
|
};
|
|
3516
3724
|
var MetadataFieldTypeValues = {
|
|
3517
|
-
string: { code: 1n, inputType: "string", storedType:
|
|
3725
|
+
string: { code: 1n, inputType: "string", storedType: import_o1js17.Field },
|
|
3518
3726
|
// Field
|
|
3519
3727
|
text: { code: 2n, inputType: "string", storedType: Text },
|
|
3520
3728
|
// Text
|
|
@@ -3522,17 +3730,40 @@ var MetadataFieldTypeValues = {
|
|
|
3522
3730
|
// Text
|
|
3523
3731
|
url: { code: 4n, inputType: "string", storedType: Text },
|
|
3524
3732
|
// Text
|
|
3525
|
-
field: { code: 5n, inputType:
|
|
3733
|
+
field: { code: 5n, inputType: import_o1js17.Field, storedType: import_o1js17.Field },
|
|
3526
3734
|
// Field
|
|
3527
3735
|
map: { code: 6n, inputType: Metadata, storedType: Metadata },
|
|
3528
3736
|
// Metadata
|
|
3529
|
-
tree: { code: 7n, inputType: MetadataTree, storedType: MetadataTree }
|
|
3737
|
+
tree: { code: 7n, inputType: MetadataTree, storedType: MetadataTree },
|
|
3530
3738
|
// MetadataTree
|
|
3739
|
+
number: { code: 8n, inputType: import_o1js17.UInt64, storedType: import_o1js17.UInt64 },
|
|
3740
|
+
// UInt64
|
|
3741
|
+
address: { code: 9n, inputType: import_o1js17.PublicKey, storedType: MinaAddress }
|
|
3742
|
+
// MinaAddress
|
|
3531
3743
|
};
|
|
3532
3744
|
|
|
3745
|
+
// dist/node/metadata/pin.js
|
|
3746
|
+
var import_storage5 = require("@silvana-one/storage");
|
|
3747
|
+
async function pinMetadata(metadata) {
|
|
3748
|
+
const privateMetadata = JSON.stringify(metadata.toJSON(true), null, 2);
|
|
3749
|
+
const ipfsHash = await (0, import_storage5.pinJSON)({
|
|
3750
|
+
data: metadata.toJSON(false),
|
|
3751
|
+
name: "nft-metadata"
|
|
3752
|
+
});
|
|
3753
|
+
if (!ipfsHash)
|
|
3754
|
+
throw new Error("Failed to pin metadata");
|
|
3755
|
+
return {
|
|
3756
|
+
name: metadata.name,
|
|
3757
|
+
ipfsHash,
|
|
3758
|
+
metadataRoot: metadata.map.root,
|
|
3759
|
+
privateMetadata,
|
|
3760
|
+
serializedMap: (0, import_storage5.serializeIndexedMap)(metadata.map)
|
|
3761
|
+
};
|
|
3762
|
+
}
|
|
3763
|
+
|
|
3533
3764
|
// dist/node/zkprogram-example/update.js
|
|
3534
|
-
var
|
|
3535
|
-
var NFTProgram = (0,
|
|
3765
|
+
var import_o1js18 = require("o1js");
|
|
3766
|
+
var NFTProgram = (0, import_o1js18.ZkProgram)({
|
|
3536
3767
|
name: "NFTProgram",
|
|
3537
3768
|
publicInput: NFTState,
|
|
3538
3769
|
publicOutput: NFTState,
|
|
@@ -3548,7 +3779,7 @@ var NFTProgram = (0, import_o1js16.ZkProgram)({
|
|
|
3548
3779
|
* The method returns an updated NFT state with the new metadata root and increments the version.
|
|
3549
3780
|
*/
|
|
3550
3781
|
insertMetadata: {
|
|
3551
|
-
privateInputs: [MetadataMap,
|
|
3782
|
+
privateInputs: [MetadataMap, import_o1js18.Field, import_o1js18.Field, import_o1js18.Signature],
|
|
3552
3783
|
auxiliaryOutput: MetadataMap,
|
|
3553
3784
|
async method(initialState, metadata, key, value, signature) {
|
|
3554
3785
|
signature.verify(initialState.owner, [
|
|
@@ -3588,7 +3819,7 @@ var NFTProgram = (0, import_o1js16.ZkProgram)({
|
|
|
3588
3819
|
* The method returns the public output of the second proof as the new merged NFT state.
|
|
3589
3820
|
*/
|
|
3590
3821
|
merge: {
|
|
3591
|
-
privateInputs: [
|
|
3822
|
+
privateInputs: [import_o1js18.SelfProof, import_o1js18.SelfProof],
|
|
3592
3823
|
async method(initialState, proof1, proof2) {
|
|
3593
3824
|
proof1.verify();
|
|
3594
3825
|
proof2.verify();
|
|
@@ -3603,9 +3834,9 @@ var NFTProgram = (0, import_o1js16.ZkProgram)({
|
|
|
3603
3834
|
});
|
|
3604
3835
|
|
|
3605
3836
|
// dist/node/zkprogram-example/game.js
|
|
3606
|
-
var
|
|
3607
|
-
var
|
|
3608
|
-
var NFTGameProgram = (0,
|
|
3837
|
+
var import_o1js19 = require("o1js");
|
|
3838
|
+
var import_storage6 = require("@silvana-one/storage");
|
|
3839
|
+
var NFTGameProgram = (0, import_o1js19.ZkProgram)({
|
|
3609
3840
|
name: "NFTGameProgram",
|
|
3610
3841
|
publicInput: NFTState,
|
|
3611
3842
|
publicOutput: NFTState,
|
|
@@ -3621,7 +3852,7 @@ var NFTGameProgram = (0, import_o1js17.ZkProgram)({
|
|
|
3621
3852
|
* The method returns an updated NFT state with the new metadata root and increments the version.
|
|
3622
3853
|
*/
|
|
3623
3854
|
updateMetadataAndOwner: {
|
|
3624
|
-
privateInputs: [MetadataMap,
|
|
3855
|
+
privateInputs: [MetadataMap, import_o1js19.PublicKey, import_o1js19.Field, import_o1js19.Field, import_storage6.Storage, import_o1js19.PublicKey],
|
|
3625
3856
|
auxiliaryOutput: MetadataMap,
|
|
3626
3857
|
async method(initialState, metadata, contract, score, color, storage, owner) {
|
|
3627
3858
|
metadata.root.assertEquals(initialState.metadata);
|
|
@@ -3636,8 +3867,8 @@ var NFTGameProgram = (0, import_o1js17.ZkProgram)({
|
|
|
3636
3867
|
type: "field"
|
|
3637
3868
|
}).hash().assertEquals(metadata.get(fieldFromString("contractIsOdd")));
|
|
3638
3869
|
contract.assertEquals(initialState.oracleAddress);
|
|
3639
|
-
const metadataRoot = await
|
|
3640
|
-
const fetchResult = await fetch((0,
|
|
3870
|
+
const metadataRoot = await import_o1js19.Provable.witnessAsync(import_o1js19.Field, async () => {
|
|
3871
|
+
const fetchResult = await fetch((0, import_storage6.createIpfsURL)({ hash: storage.toString() }));
|
|
3641
3872
|
if (!fetchResult.ok) {
|
|
3642
3873
|
throw new Error("Failed to fetch metadata");
|
|
3643
3874
|
}
|
|
@@ -3652,7 +3883,7 @@ var NFTGameProgram = (0, import_o1js17.ZkProgram)({
|
|
|
3652
3883
|
return metadata2.map.root;
|
|
3653
3884
|
});
|
|
3654
3885
|
metadataRoot.assertEquals(metadata.root);
|
|
3655
|
-
owner.equals(initialState.owner).or(score.equals((0,
|
|
3886
|
+
owner.equals(initialState.owner).or(score.equals((0, import_o1js19.Field)(7))).assertTrue();
|
|
3656
3887
|
return {
|
|
3657
3888
|
publicOutput: new NFTState({
|
|
3658
3889
|
metadata: metadata.root,
|
|
@@ -3673,7 +3904,7 @@ var NFTGameProgram = (0, import_o1js17.ZkProgram)({
|
|
|
3673
3904
|
}
|
|
3674
3905
|
},
|
|
3675
3906
|
merge: {
|
|
3676
|
-
privateInputs: [
|
|
3907
|
+
privateInputs: [import_o1js19.SelfProof, import_o1js19.SelfProof],
|
|
3677
3908
|
async method(initialState, proof1, proof2) {
|
|
3678
3909
|
proof1.verify();
|
|
3679
3910
|
proof2.verify();
|
|
@@ -3689,57 +3920,57 @@ var NFTGameProgram = (0, import_o1js17.ZkProgram)({
|
|
|
3689
3920
|
|
|
3690
3921
|
// dist/node/marketplace/bid.js
|
|
3691
3922
|
var import_tslib8 = require("tslib");
|
|
3692
|
-
var
|
|
3693
|
-
var
|
|
3923
|
+
var import_o1js21 = require("o1js");
|
|
3924
|
+
var import_storage8 = require("@silvana-one/storage");
|
|
3694
3925
|
|
|
3695
3926
|
// dist/node/marketplace/types.js
|
|
3696
|
-
var
|
|
3697
|
-
var
|
|
3698
|
-
var NFTAddress = class extends (0,
|
|
3699
|
-
collection:
|
|
3700
|
-
nft:
|
|
3927
|
+
var import_o1js20 = require("o1js");
|
|
3928
|
+
var import_storage7 = require("@silvana-one/storage");
|
|
3929
|
+
var NFTAddress = class extends (0, import_o1js20.Struct)({
|
|
3930
|
+
collection: import_o1js20.PublicKey,
|
|
3931
|
+
nft: import_o1js20.PublicKey
|
|
3701
3932
|
}) {
|
|
3702
3933
|
};
|
|
3703
|
-
var SellEvent = class extends (0,
|
|
3704
|
-
collection:
|
|
3705
|
-
nft:
|
|
3706
|
-
price:
|
|
3934
|
+
var SellEvent = class extends (0, import_o1js20.Struct)({
|
|
3935
|
+
collection: import_o1js20.PublicKey,
|
|
3936
|
+
nft: import_o1js20.PublicKey,
|
|
3937
|
+
price: import_o1js20.UInt64
|
|
3707
3938
|
}) {
|
|
3708
3939
|
};
|
|
3709
|
-
var DepositEvent = class extends (0,
|
|
3710
|
-
buyer:
|
|
3711
|
-
amount:
|
|
3712
|
-
maxPoints:
|
|
3940
|
+
var DepositEvent = class extends (0, import_o1js20.Struct)({
|
|
3941
|
+
buyer: import_o1js20.PublicKey,
|
|
3942
|
+
amount: import_o1js20.UInt64,
|
|
3943
|
+
maxPoints: import_o1js20.UInt64
|
|
3713
3944
|
}) {
|
|
3714
3945
|
};
|
|
3715
|
-
var WithdrawEvent = class extends (0,
|
|
3716
|
-
buyer:
|
|
3717
|
-
amount:
|
|
3718
|
-
maxPoints:
|
|
3946
|
+
var WithdrawEvent = class extends (0, import_o1js20.Struct)({
|
|
3947
|
+
buyer: import_o1js20.PublicKey,
|
|
3948
|
+
amount: import_o1js20.UInt64,
|
|
3949
|
+
maxPoints: import_o1js20.UInt64
|
|
3719
3950
|
}) {
|
|
3720
3951
|
};
|
|
3721
|
-
var BidEvent = class extends (0,
|
|
3722
|
-
bids:
|
|
3723
|
-
whitelist:
|
|
3724
|
-
storage:
|
|
3952
|
+
var BidEvent = class extends (0, import_o1js20.Struct)({
|
|
3953
|
+
bids: import_o1js20.Field,
|
|
3954
|
+
whitelist: import_o1js20.Field,
|
|
3955
|
+
storage: import_storage7.Storage
|
|
3725
3956
|
}) {
|
|
3726
3957
|
};
|
|
3727
3958
|
|
|
3728
3959
|
// dist/node/marketplace/bid.js
|
|
3729
|
-
var Bid = class _Bid extends (0,
|
|
3730
|
-
price:
|
|
3731
|
-
points:
|
|
3960
|
+
var Bid = class _Bid extends (0, import_o1js21.Struct)({
|
|
3961
|
+
price: import_o1js21.UInt64,
|
|
3962
|
+
points: import_o1js21.UInt64
|
|
3732
3963
|
}) {
|
|
3733
3964
|
pack() {
|
|
3734
|
-
return
|
|
3965
|
+
return import_o1js21.Field.fromBits([
|
|
3735
3966
|
...this.price.value.toBits(64),
|
|
3736
3967
|
...this.points.value.toBits(64)
|
|
3737
3968
|
]);
|
|
3738
3969
|
}
|
|
3739
3970
|
static unpack(field) {
|
|
3740
3971
|
const bits = field.toBits(64 + 64);
|
|
3741
|
-
const price =
|
|
3742
|
-
const points =
|
|
3972
|
+
const price = import_o1js21.UInt64.Unsafe.fromField(import_o1js21.Field.fromBits(bits.slice(0, 64)));
|
|
3973
|
+
const points = import_o1js21.UInt64.Unsafe.fromField(import_o1js21.Field.fromBits(bits.slice(64, 64 + 64)));
|
|
3743
3974
|
return new _Bid({
|
|
3744
3975
|
price,
|
|
3745
3976
|
points
|
|
@@ -3748,20 +3979,20 @@ var Bid = class _Bid extends (0, import_o1js19.Struct)({
|
|
|
3748
3979
|
};
|
|
3749
3980
|
function BidFactory(params) {
|
|
3750
3981
|
const { collectionContract } = params;
|
|
3751
|
-
class NonFungibleTokenBidContract extends
|
|
3982
|
+
class NonFungibleTokenBidContract extends import_o1js21.SmartContract {
|
|
3752
3983
|
constructor() {
|
|
3753
3984
|
super(...arguments);
|
|
3754
|
-
this.buyer = (0,
|
|
3755
|
-
this.whitelist = (0,
|
|
3756
|
-
this.bids = (0,
|
|
3757
|
-
this.storage = (0,
|
|
3758
|
-
this.maxPoints = (0,
|
|
3759
|
-
this.consumedPoints = (0,
|
|
3985
|
+
this.buyer = (0, import_o1js21.State)();
|
|
3986
|
+
this.whitelist = (0, import_o1js21.State)();
|
|
3987
|
+
this.bids = (0, import_o1js21.State)();
|
|
3988
|
+
this.storage = (0, import_o1js21.State)();
|
|
3989
|
+
this.maxPoints = (0, import_o1js21.State)();
|
|
3990
|
+
this.consumedPoints = (0, import_o1js21.State)();
|
|
3760
3991
|
this.events = {
|
|
3761
3992
|
deposit: DepositEvent,
|
|
3762
3993
|
withdraw: WithdrawEvent,
|
|
3763
3994
|
sell: SellEvent,
|
|
3764
|
-
updateWhitelist:
|
|
3995
|
+
updateWhitelist: import_storage8.Whitelist,
|
|
3765
3996
|
bid: BidEvent
|
|
3766
3997
|
};
|
|
3767
3998
|
}
|
|
@@ -3771,19 +4002,19 @@ function BidFactory(params) {
|
|
|
3771
4002
|
this.bids.set(args.bids);
|
|
3772
4003
|
this.storage.set(args.storage);
|
|
3773
4004
|
this.account.permissions.set({
|
|
3774
|
-
...
|
|
3775
|
-
send:
|
|
3776
|
-
setVerificationKey:
|
|
3777
|
-
setPermissions:
|
|
4005
|
+
...import_o1js21.Permissions.default(),
|
|
4006
|
+
send: import_o1js21.Permissions.proof(),
|
|
4007
|
+
setVerificationKey: import_o1js21.Permissions.VerificationKey.impossibleDuringCurrentVersion(),
|
|
4008
|
+
setPermissions: import_o1js21.Permissions.impossible()
|
|
3778
4009
|
});
|
|
3779
4010
|
}
|
|
3780
4011
|
async initialize(amount, maxPoints) {
|
|
3781
|
-
this.account.provedState.requireEquals((0,
|
|
4012
|
+
this.account.provedState.requireEquals((0, import_o1js21.Bool)(false));
|
|
3782
4013
|
const buyer = this.sender.getUnconstrained();
|
|
3783
|
-
const buyerUpdate =
|
|
3784
|
-
buyerUpdate.balance.subInPlace(amount.add(
|
|
4014
|
+
const buyerUpdate = import_o1js21.AccountUpdate.createSigned(buyer);
|
|
4015
|
+
buyerUpdate.balance.subInPlace(amount.add(import_o1js21.UInt64.from(1e9)));
|
|
3785
4016
|
this.self.balance.addInPlace(amount);
|
|
3786
|
-
buyerUpdate.body.useFullCommitment = (0,
|
|
4017
|
+
buyerUpdate.body.useFullCommitment = (0, import_o1js21.Bool)(true);
|
|
3787
4018
|
this.buyer.set(buyer);
|
|
3788
4019
|
this.maxPoints.set(maxPoints);
|
|
3789
4020
|
this.emitEvent("deposit", new DepositEvent({
|
|
@@ -3797,13 +4028,13 @@ function BidFactory(params) {
|
|
|
3797
4028
|
return new CollectionContract(address);
|
|
3798
4029
|
}
|
|
3799
4030
|
async deposit(amount, maxPoints) {
|
|
3800
|
-
amount.equals(
|
|
4031
|
+
amount.equals(import_o1js21.UInt64.from(0)).assertFalse();
|
|
3801
4032
|
const sender = this.sender.getUnconstrained();
|
|
3802
4033
|
const buyer = this.buyer.getAndRequireEquals();
|
|
3803
4034
|
sender.assertEquals(buyer);
|
|
3804
|
-
const buyerUpdate =
|
|
4035
|
+
const buyerUpdate = import_o1js21.AccountUpdate.createSigned(buyer);
|
|
3805
4036
|
buyerUpdate.send({ to: this.address, amount });
|
|
3806
|
-
buyerUpdate.body.useFullCommitment = (0,
|
|
4037
|
+
buyerUpdate.body.useFullCommitment = (0, import_o1js21.Bool)(true);
|
|
3807
4038
|
this.maxPoints.set(maxPoints);
|
|
3808
4039
|
this.emitEvent("deposit", new DepositEvent({
|
|
3809
4040
|
buyer,
|
|
@@ -3812,15 +4043,15 @@ function BidFactory(params) {
|
|
|
3812
4043
|
}));
|
|
3813
4044
|
}
|
|
3814
4045
|
async withdraw(amount, maxPoints) {
|
|
3815
|
-
amount.equals(
|
|
3816
|
-
this.account.balance.requireBetween(amount,
|
|
4046
|
+
amount.equals(import_o1js21.UInt64.from(0)).assertFalse();
|
|
4047
|
+
this.account.balance.requireBetween(amount, import_o1js21.UInt64.MAXINT());
|
|
3817
4048
|
const buyer = this.buyer.getAndRequireEquals();
|
|
3818
4049
|
const sender = this.sender.getUnconstrained();
|
|
3819
|
-
const senderUpdate =
|
|
3820
|
-
senderUpdate.body.useFullCommitment = (0,
|
|
4050
|
+
const senderUpdate = import_o1js21.AccountUpdate.createSigned(sender);
|
|
4051
|
+
senderUpdate.body.useFullCommitment = (0, import_o1js21.Bool)(true);
|
|
3821
4052
|
sender.assertEquals(buyer);
|
|
3822
4053
|
let bidUpdate = this.send({ to: senderUpdate, amount });
|
|
3823
|
-
bidUpdate.body.useFullCommitment = (0,
|
|
4054
|
+
bidUpdate.body.useFullCommitment = (0, import_o1js21.Bool)(true);
|
|
3824
4055
|
this.maxPoints.set(maxPoints);
|
|
3825
4056
|
this.emitEvent("withdraw", new WithdrawEvent({
|
|
3826
4057
|
buyer,
|
|
@@ -3835,11 +4066,11 @@ function BidFactory(params) {
|
|
|
3835
4066
|
const collection = new Collection2(nftAddress.collection);
|
|
3836
4067
|
await collection.transferBySignature(new TransferParams({
|
|
3837
4068
|
address: nftAddress.nft,
|
|
3838
|
-
from:
|
|
4069
|
+
from: import_o1js21.PublicKey.empty(),
|
|
3839
4070
|
to: buyer,
|
|
3840
4071
|
price: UInt64Option.fromValue(price),
|
|
3841
4072
|
context: new NFTTransactionContext({
|
|
3842
|
-
custom: [(0,
|
|
4073
|
+
custom: [(0, import_o1js21.Field)(0), (0, import_o1js21.Field)(0), (0, import_o1js21.Field)(0)]
|
|
3843
4074
|
})
|
|
3844
4075
|
}));
|
|
3845
4076
|
}
|
|
@@ -3850,37 +4081,37 @@ function BidFactory(params) {
|
|
|
3850
4081
|
const collection = new Collection2(nftAddress.collection);
|
|
3851
4082
|
await collection.approvedTransferBySignature(new TransferParams({
|
|
3852
4083
|
address: nftAddress.nft,
|
|
3853
|
-
from:
|
|
4084
|
+
from: import_o1js21.PublicKey.empty(),
|
|
3854
4085
|
to: buyer,
|
|
3855
4086
|
price: UInt64Option.fromValue(price),
|
|
3856
4087
|
context: new NFTTransactionContext({
|
|
3857
|
-
custom: [(0,
|
|
4088
|
+
custom: [(0, import_o1js21.Field)(0), (0, import_o1js21.Field)(0), (0, import_o1js21.Field)(0)]
|
|
3858
4089
|
})
|
|
3859
4090
|
}));
|
|
3860
4091
|
}
|
|
3861
4092
|
async _sell(nftAddress, price) {
|
|
3862
|
-
price.equals(
|
|
3863
|
-
const key =
|
|
4093
|
+
price.equals(import_o1js21.UInt64.from(0)).assertFalse();
|
|
4094
|
+
const key = import_o1js21.Poseidon.hashPacked(NFTAddress, nftAddress);
|
|
3864
4095
|
const storage = this.storage.getAndRequireEquals();
|
|
3865
|
-
const bids = new
|
|
4096
|
+
const bids = new import_storage8.OffChainList({
|
|
3866
4097
|
root: this.bids.getAndRequireEquals(),
|
|
3867
4098
|
storage
|
|
3868
4099
|
});
|
|
3869
4100
|
const bid = Bid.unpack((await bids.getValue(key, "bids")).assertSome("bid not found"));
|
|
3870
4101
|
price.assertLessThanOrEqual(bid.price, "price is too high");
|
|
3871
|
-
this.account.balance.requireBetween(price,
|
|
4102
|
+
this.account.balance.requireBetween(price, import_o1js21.UInt64.MAXINT());
|
|
3872
4103
|
const consumedPoints = this.consumedPoints.getAndRequireEquals();
|
|
3873
4104
|
const maxPoints = this.maxPoints.getAndRequireEquals();
|
|
3874
4105
|
const newConsumedPoints = consumedPoints.add(bid.points);
|
|
3875
4106
|
newConsumedPoints.assertLessThanOrEqual(maxPoints, "consumed points exceed max points");
|
|
3876
4107
|
this.consumedPoints.set(newConsumedPoints);
|
|
3877
4108
|
const seller = this.sender.getUnconstrained();
|
|
3878
|
-
const sellerUpdate =
|
|
4109
|
+
const sellerUpdate = import_o1js21.AccountUpdate.createSigned(seller);
|
|
3879
4110
|
sellerUpdate.balance.addInPlace(price);
|
|
3880
4111
|
this.self.balance.subInPlace(price);
|
|
3881
|
-
sellerUpdate.body.useFullCommitment = (0,
|
|
3882
|
-
const whitelist = new
|
|
3883
|
-
list: new
|
|
4112
|
+
sellerUpdate.body.useFullCommitment = (0, import_o1js21.Bool)(true);
|
|
4113
|
+
const whitelist = new import_storage8.Whitelist({
|
|
4114
|
+
list: new import_storage8.OffChainList({
|
|
3884
4115
|
root: this.whitelist.getAndRequireEquals(),
|
|
3885
4116
|
storage
|
|
3886
4117
|
})
|
|
@@ -3888,7 +4119,7 @@ function BidFactory(params) {
|
|
|
3888
4119
|
const whitelistedAmount = await whitelist.getWhitelistedAmount(seller, "whitelist");
|
|
3889
4120
|
const whitelistDisabled = whitelist.isNone();
|
|
3890
4121
|
whitelistedAmount.isSome.or(whitelistDisabled).assertTrue("Cannot buy from non-whitelisted address");
|
|
3891
|
-
const maxPrice =
|
|
4122
|
+
const maxPrice = import_o1js21.Provable.if(whitelistDisabled, import_o1js21.UInt64.MAXINT(), whitelistedAmount.value);
|
|
3892
4123
|
price.assertLessThanOrEqual(maxPrice, "price is higher than whitelisted price");
|
|
3893
4124
|
this.emitEvent("sell", new SellEvent({
|
|
3894
4125
|
collection: nftAddress.collection,
|
|
@@ -3899,8 +4130,8 @@ function BidFactory(params) {
|
|
|
3899
4130
|
async bid(bids, whitelist, storage) {
|
|
3900
4131
|
const buyer = this.buyer.getAndRequireEquals();
|
|
3901
4132
|
const sender = this.sender.getUnconstrained();
|
|
3902
|
-
const senderUpdate =
|
|
3903
|
-
senderUpdate.body.useFullCommitment = (0,
|
|
4133
|
+
const senderUpdate = import_o1js21.AccountUpdate.createSigned(sender);
|
|
4134
|
+
senderUpdate.body.useFullCommitment = (0, import_o1js21.Bool)(true);
|
|
3904
4135
|
sender.assertEquals(buyer);
|
|
3905
4136
|
this.bids.set(bids);
|
|
3906
4137
|
this.whitelist.set(whitelist);
|
|
@@ -3909,63 +4140,63 @@ function BidFactory(params) {
|
|
|
3909
4140
|
}
|
|
3910
4141
|
}
|
|
3911
4142
|
(0, import_tslib8.__decorate)([
|
|
3912
|
-
(0,
|
|
4143
|
+
(0, import_o1js21.state)(import_o1js21.PublicKey),
|
|
3913
4144
|
(0, import_tslib8.__metadata)("design:type", Object)
|
|
3914
4145
|
], NonFungibleTokenBidContract.prototype, "buyer", void 0);
|
|
3915
4146
|
(0, import_tslib8.__decorate)([
|
|
3916
|
-
(0,
|
|
4147
|
+
(0, import_o1js21.state)(import_o1js21.Field),
|
|
3917
4148
|
(0, import_tslib8.__metadata)("design:type", Object)
|
|
3918
4149
|
], NonFungibleTokenBidContract.prototype, "whitelist", void 0);
|
|
3919
4150
|
(0, import_tslib8.__decorate)([
|
|
3920
|
-
(0,
|
|
4151
|
+
(0, import_o1js21.state)(import_o1js21.Field),
|
|
3921
4152
|
(0, import_tslib8.__metadata)("design:type", Object)
|
|
3922
4153
|
], NonFungibleTokenBidContract.prototype, "bids", void 0);
|
|
3923
4154
|
(0, import_tslib8.__decorate)([
|
|
3924
|
-
(0,
|
|
4155
|
+
(0, import_o1js21.state)(import_storage8.Storage),
|
|
3925
4156
|
(0, import_tslib8.__metadata)("design:type", Object)
|
|
3926
4157
|
], NonFungibleTokenBidContract.prototype, "storage", void 0);
|
|
3927
4158
|
(0, import_tslib8.__decorate)([
|
|
3928
|
-
(0,
|
|
4159
|
+
(0, import_o1js21.state)(import_o1js21.UInt64),
|
|
3929
4160
|
(0, import_tslib8.__metadata)("design:type", Object)
|
|
3930
4161
|
], NonFungibleTokenBidContract.prototype, "maxPoints", void 0);
|
|
3931
4162
|
(0, import_tslib8.__decorate)([
|
|
3932
|
-
(0,
|
|
4163
|
+
(0, import_o1js21.state)(import_o1js21.UInt64),
|
|
3933
4164
|
(0, import_tslib8.__metadata)("design:type", Object)
|
|
3934
4165
|
], NonFungibleTokenBidContract.prototype, "consumedPoints", void 0);
|
|
3935
4166
|
(0, import_tslib8.__decorate)([
|
|
3936
|
-
|
|
4167
|
+
import_o1js21.method,
|
|
3937
4168
|
(0, import_tslib8.__metadata)("design:type", Function),
|
|
3938
|
-
(0, import_tslib8.__metadata)("design:paramtypes", [
|
|
4169
|
+
(0, import_tslib8.__metadata)("design:paramtypes", [import_o1js21.UInt64, import_o1js21.UInt64]),
|
|
3939
4170
|
(0, import_tslib8.__metadata)("design:returntype", Promise)
|
|
3940
4171
|
], NonFungibleTokenBidContract.prototype, "initialize", null);
|
|
3941
4172
|
(0, import_tslib8.__decorate)([
|
|
3942
|
-
|
|
4173
|
+
import_o1js21.method,
|
|
3943
4174
|
(0, import_tslib8.__metadata)("design:type", Function),
|
|
3944
|
-
(0, import_tslib8.__metadata)("design:paramtypes", [
|
|
4175
|
+
(0, import_tslib8.__metadata)("design:paramtypes", [import_o1js21.UInt64, import_o1js21.UInt64]),
|
|
3945
4176
|
(0, import_tslib8.__metadata)("design:returntype", Promise)
|
|
3946
4177
|
], NonFungibleTokenBidContract.prototype, "deposit", null);
|
|
3947
4178
|
(0, import_tslib8.__decorate)([
|
|
3948
|
-
|
|
4179
|
+
import_o1js21.method,
|
|
3949
4180
|
(0, import_tslib8.__metadata)("design:type", Function),
|
|
3950
|
-
(0, import_tslib8.__metadata)("design:paramtypes", [
|
|
4181
|
+
(0, import_tslib8.__metadata)("design:paramtypes", [import_o1js21.UInt64, import_o1js21.UInt64]),
|
|
3951
4182
|
(0, import_tslib8.__metadata)("design:returntype", Promise)
|
|
3952
4183
|
], NonFungibleTokenBidContract.prototype, "withdraw", null);
|
|
3953
4184
|
(0, import_tslib8.__decorate)([
|
|
3954
|
-
|
|
4185
|
+
import_o1js21.method,
|
|
3955
4186
|
(0, import_tslib8.__metadata)("design:type", Function),
|
|
3956
|
-
(0, import_tslib8.__metadata)("design:paramtypes", [NFTAddress,
|
|
4187
|
+
(0, import_tslib8.__metadata)("design:paramtypes", [NFTAddress, import_o1js21.UInt64]),
|
|
3957
4188
|
(0, import_tslib8.__metadata)("design:returntype", Promise)
|
|
3958
4189
|
], NonFungibleTokenBidContract.prototype, "sell", null);
|
|
3959
4190
|
(0, import_tslib8.__decorate)([
|
|
3960
|
-
|
|
4191
|
+
import_o1js21.method,
|
|
3961
4192
|
(0, import_tslib8.__metadata)("design:type", Function),
|
|
3962
|
-
(0, import_tslib8.__metadata)("design:paramtypes", [NFTAddress,
|
|
4193
|
+
(0, import_tslib8.__metadata)("design:paramtypes", [NFTAddress, import_o1js21.UInt64]),
|
|
3963
4194
|
(0, import_tslib8.__metadata)("design:returntype", Promise)
|
|
3964
4195
|
], NonFungibleTokenBidContract.prototype, "approvedSell", null);
|
|
3965
4196
|
(0, import_tslib8.__decorate)([
|
|
3966
|
-
|
|
4197
|
+
import_o1js21.method,
|
|
3967
4198
|
(0, import_tslib8.__metadata)("design:type", Function),
|
|
3968
|
-
(0, import_tslib8.__metadata)("design:paramtypes", [
|
|
4199
|
+
(0, import_tslib8.__metadata)("design:paramtypes", [import_o1js21.Field, import_o1js21.Field, import_storage8.Storage]),
|
|
3969
4200
|
(0, import_tslib8.__metadata)("design:returntype", Promise)
|
|
3970
4201
|
], NonFungibleTokenBidContract.prototype, "bid", null);
|
|
3971
4202
|
return NonFungibleTokenBidContract;
|
|
@@ -3973,17 +4204,17 @@ function BidFactory(params) {
|
|
|
3973
4204
|
|
|
3974
4205
|
// dist/node/marketplace/offer.js
|
|
3975
4206
|
var import_tslib9 = require("tslib");
|
|
3976
|
-
var
|
|
4207
|
+
var import_o1js22 = require("o1js");
|
|
3977
4208
|
function OfferFactory(params) {
|
|
3978
4209
|
const { collectionContract } = params;
|
|
3979
|
-
class NonFungibleTokenOfferContract extends
|
|
4210
|
+
class NonFungibleTokenOfferContract extends import_o1js22.SmartContract {
|
|
3980
4211
|
constructor() {
|
|
3981
4212
|
super(...arguments);
|
|
3982
|
-
this.owner = (0,
|
|
3983
|
-
this.price = (0,
|
|
3984
|
-
this.collection = (0,
|
|
3985
|
-
this.nft = (0,
|
|
3986
|
-
this.insideBuy = (0,
|
|
4213
|
+
this.owner = (0, import_o1js22.State)();
|
|
4214
|
+
this.price = (0, import_o1js22.State)();
|
|
4215
|
+
this.collection = (0, import_o1js22.State)();
|
|
4216
|
+
this.nft = (0, import_o1js22.State)();
|
|
4217
|
+
this.insideBuy = (0, import_o1js22.State)();
|
|
3987
4218
|
this.events = {
|
|
3988
4219
|
buy: TransferEvent
|
|
3989
4220
|
};
|
|
@@ -3994,12 +4225,12 @@ function OfferFactory(params) {
|
|
|
3994
4225
|
this.price.set(args.price);
|
|
3995
4226
|
this.collection.set(args.collection);
|
|
3996
4227
|
this.nft.set(args.nft);
|
|
3997
|
-
this.insideBuy.set((0,
|
|
4228
|
+
this.insideBuy.set((0, import_o1js22.Bool)(false));
|
|
3998
4229
|
this.account.permissions.set({
|
|
3999
|
-
...
|
|
4000
|
-
send:
|
|
4001
|
-
setVerificationKey:
|
|
4002
|
-
setPermissions:
|
|
4230
|
+
...import_o1js22.Permissions.default(),
|
|
4231
|
+
send: import_o1js22.Permissions.proof(),
|
|
4232
|
+
setVerificationKey: import_o1js22.Permissions.VerificationKey.impossibleDuringCurrentVersion(),
|
|
4233
|
+
setPermissions: import_o1js22.Permissions.impossible()
|
|
4003
4234
|
});
|
|
4004
4235
|
}
|
|
4005
4236
|
getCollectionContract(address) {
|
|
@@ -4009,7 +4240,7 @@ function OfferFactory(params) {
|
|
|
4009
4240
|
async buy() {
|
|
4010
4241
|
const insideBuy = this.insideBuy.getAndRequireEquals();
|
|
4011
4242
|
insideBuy.assertFalse("Already inside buy method");
|
|
4012
|
-
this.insideBuy.set((0,
|
|
4243
|
+
this.insideBuy.set((0, import_o1js22.Bool)(true));
|
|
4013
4244
|
const collectionAddress = this.collection.getAndRequireEquals();
|
|
4014
4245
|
const nftAddress = this.nft.getAndRequireEquals();
|
|
4015
4246
|
const price = this.price.getAndRequireEquals();
|
|
@@ -4020,7 +4251,7 @@ function OfferFactory(params) {
|
|
|
4020
4251
|
to: this.sender.getUnconstrained(),
|
|
4021
4252
|
price: UInt64Option.fromValue(price),
|
|
4022
4253
|
context: new NFTTransactionContext({
|
|
4023
|
-
custom: [(0,
|
|
4254
|
+
custom: [(0, import_o1js22.Field)(0), (0, import_o1js22.Field)(0), (0, import_o1js22.Field)(0)]
|
|
4024
4255
|
})
|
|
4025
4256
|
});
|
|
4026
4257
|
}
|
|
@@ -4031,7 +4262,7 @@ function OfferFactory(params) {
|
|
|
4031
4262
|
// await collection.sellWithApproval(nftAddress.nft, price, buyer);
|
|
4032
4263
|
// }
|
|
4033
4264
|
async canTransfer(params2) {
|
|
4034
|
-
this.insideBuy.requireEquals((0,
|
|
4265
|
+
this.insideBuy.requireEquals((0, import_o1js22.Bool)(true));
|
|
4035
4266
|
const collectionAddress = this.collection.getAndRequireEquals();
|
|
4036
4267
|
const nftAddress = this.nft.getAndRequireEquals();
|
|
4037
4268
|
const owner = this.owner.getAndRequireEquals();
|
|
@@ -4043,49 +4274,49 @@ function OfferFactory(params) {
|
|
|
4043
4274
|
params2.approved.assertEquals(this.address);
|
|
4044
4275
|
params2.price.assertSome().assertEquals(price);
|
|
4045
4276
|
params2.to.assertEquals(sender);
|
|
4046
|
-
params2.fee.orElse(
|
|
4047
|
-
const payment = price.sub(params2.fee.orElse(
|
|
4048
|
-
const senderUpdate =
|
|
4049
|
-
senderUpdate.account.balance.requireBetween(payment,
|
|
4277
|
+
params2.fee.orElse(import_o1js22.UInt64.zero).assertLessThan(price, "Fee is too high");
|
|
4278
|
+
const payment = price.sub(params2.fee.orElse(import_o1js22.UInt64.zero));
|
|
4279
|
+
const senderUpdate = import_o1js22.AccountUpdate.createSigned(sender);
|
|
4280
|
+
senderUpdate.account.balance.requireBetween(payment, import_o1js22.UInt64.MAXINT());
|
|
4050
4281
|
senderUpdate.balance.subInPlace(payment);
|
|
4051
|
-
const ownerUpdate =
|
|
4282
|
+
const ownerUpdate = import_o1js22.AccountUpdate.create(owner);
|
|
4052
4283
|
ownerUpdate.balance.addInPlace(payment);
|
|
4053
|
-
senderUpdate.body.useFullCommitment = (0,
|
|
4054
|
-
ownerUpdate.body.useFullCommitment = (0,
|
|
4284
|
+
senderUpdate.body.useFullCommitment = (0, import_o1js22.Bool)(true);
|
|
4285
|
+
ownerUpdate.body.useFullCommitment = (0, import_o1js22.Bool)(true);
|
|
4055
4286
|
this.emitEvent("buy", new TransferEvent({
|
|
4056
4287
|
...params2
|
|
4057
4288
|
}));
|
|
4058
|
-
return (0,
|
|
4289
|
+
return (0, import_o1js22.Bool)(true);
|
|
4059
4290
|
}
|
|
4060
4291
|
}
|
|
4061
4292
|
(0, import_tslib9.__decorate)([
|
|
4062
|
-
(0,
|
|
4293
|
+
(0, import_o1js22.state)(import_o1js22.PublicKey),
|
|
4063
4294
|
(0, import_tslib9.__metadata)("design:type", Object)
|
|
4064
4295
|
], NonFungibleTokenOfferContract.prototype, "owner", void 0);
|
|
4065
4296
|
(0, import_tslib9.__decorate)([
|
|
4066
|
-
(0,
|
|
4297
|
+
(0, import_o1js22.state)(import_o1js22.UInt64),
|
|
4067
4298
|
(0, import_tslib9.__metadata)("design:type", Object)
|
|
4068
4299
|
], NonFungibleTokenOfferContract.prototype, "price", void 0);
|
|
4069
4300
|
(0, import_tslib9.__decorate)([
|
|
4070
|
-
(0,
|
|
4301
|
+
(0, import_o1js22.state)(import_o1js22.PublicKey),
|
|
4071
4302
|
(0, import_tslib9.__metadata)("design:type", Object)
|
|
4072
4303
|
], NonFungibleTokenOfferContract.prototype, "collection", void 0);
|
|
4073
4304
|
(0, import_tslib9.__decorate)([
|
|
4074
|
-
(0,
|
|
4305
|
+
(0, import_o1js22.state)(import_o1js22.PublicKey),
|
|
4075
4306
|
(0, import_tslib9.__metadata)("design:type", Object)
|
|
4076
4307
|
], NonFungibleTokenOfferContract.prototype, "nft", void 0);
|
|
4077
4308
|
(0, import_tslib9.__decorate)([
|
|
4078
|
-
(0,
|
|
4309
|
+
(0, import_o1js22.state)(import_o1js22.Bool),
|
|
4079
4310
|
(0, import_tslib9.__metadata)("design:type", Object)
|
|
4080
4311
|
], NonFungibleTokenOfferContract.prototype, "insideBuy", void 0);
|
|
4081
4312
|
(0, import_tslib9.__decorate)([
|
|
4082
|
-
|
|
4313
|
+
import_o1js22.method,
|
|
4083
4314
|
(0, import_tslib9.__metadata)("design:type", Function),
|
|
4084
4315
|
(0, import_tslib9.__metadata)("design:paramtypes", []),
|
|
4085
4316
|
(0, import_tslib9.__metadata)("design:returntype", Promise)
|
|
4086
4317
|
], NonFungibleTokenOfferContract.prototype, "buy", null);
|
|
4087
4318
|
(0, import_tslib9.__decorate)([
|
|
4088
|
-
|
|
4319
|
+
import_o1js22.method.returns(import_o1js22.Bool),
|
|
4089
4320
|
(0, import_tslib9.__metadata)("design:type", Function),
|
|
4090
4321
|
(0, import_tslib9.__metadata)("design:paramtypes", [TransferExtendedParams]),
|
|
4091
4322
|
(0, import_tslib9.__metadata)("design:returntype", Promise)
|
|
@@ -4095,37 +4326,37 @@ function OfferFactory(params) {
|
|
|
4095
4326
|
|
|
4096
4327
|
// dist/node/marketplace/auction.js
|
|
4097
4328
|
var import_tslib10 = require("tslib");
|
|
4098
|
-
var
|
|
4329
|
+
var import_o1js23 = require("o1js");
|
|
4099
4330
|
var MAX_SALE_FEE = 1e5;
|
|
4100
4331
|
var MIN_STEP = 10;
|
|
4101
|
-
var AuctionPacked = class extends (0,
|
|
4102
|
-
ownerX:
|
|
4103
|
-
collectionX:
|
|
4104
|
-
nftX:
|
|
4105
|
-
auctioneerX:
|
|
4106
|
-
bidderX:
|
|
4107
|
-
data:
|
|
4332
|
+
var AuctionPacked = class extends (0, import_o1js23.Struct)({
|
|
4333
|
+
ownerX: import_o1js23.Field,
|
|
4334
|
+
collectionX: import_o1js23.Field,
|
|
4335
|
+
nftX: import_o1js23.Field,
|
|
4336
|
+
auctioneerX: import_o1js23.Field,
|
|
4337
|
+
bidderX: import_o1js23.Field,
|
|
4338
|
+
data: import_o1js23.Field
|
|
4108
4339
|
}) {
|
|
4109
4340
|
};
|
|
4110
|
-
var Auction = class _Auction extends (0,
|
|
4111
|
-
owner:
|
|
4112
|
-
collection:
|
|
4113
|
-
nft:
|
|
4114
|
-
auctioneer:
|
|
4115
|
-
bidder:
|
|
4116
|
-
minimumPrice:
|
|
4117
|
-
transferFee:
|
|
4341
|
+
var Auction = class _Auction extends (0, import_o1js23.Struct)({
|
|
4342
|
+
owner: import_o1js23.PublicKey,
|
|
4343
|
+
collection: import_o1js23.PublicKey,
|
|
4344
|
+
nft: import_o1js23.PublicKey,
|
|
4345
|
+
auctioneer: import_o1js23.PublicKey,
|
|
4346
|
+
bidder: import_o1js23.PublicKey,
|
|
4347
|
+
minimumPrice: import_o1js23.UInt64,
|
|
4348
|
+
transferFee: import_o1js23.UInt64,
|
|
4118
4349
|
/** The sale fee percentage (e.g., 1000 = 1%, 100 = 0.1%, 10000 = 10%, 100000 = 100%). */
|
|
4119
|
-
saleFee:
|
|
4120
|
-
auctionEndTime:
|
|
4121
|
-
withdrawPeriod:
|
|
4350
|
+
saleFee: import_o1js23.UInt32,
|
|
4351
|
+
auctionEndTime: import_o1js23.UInt32,
|
|
4352
|
+
withdrawPeriod: import_o1js23.UInt32,
|
|
4122
4353
|
// in slots
|
|
4123
|
-
isOwnerPaid:
|
|
4124
|
-
isNFTtransferred:
|
|
4125
|
-
isNFTwithdrawn:
|
|
4354
|
+
isOwnerPaid: import_o1js23.Bool,
|
|
4355
|
+
isNFTtransferred: import_o1js23.Bool,
|
|
4356
|
+
isNFTwithdrawn: import_o1js23.Bool
|
|
4126
4357
|
}) {
|
|
4127
4358
|
pack() {
|
|
4128
|
-
const data =
|
|
4359
|
+
const data = import_o1js23.Field.fromBits([
|
|
4129
4360
|
...this.minimumPrice.value.toBits(64),
|
|
4130
4361
|
...this.transferFee.value.toBits(64),
|
|
4131
4362
|
...this.saleFee.value.toBits(32),
|
|
@@ -4164,25 +4395,25 @@ var Auction = class _Auction extends (0, import_o1js21.Struct)({
|
|
|
4164
4395
|
const isOwnerPaid = bits[64 + 64 + 32 + 32 + 32 + 5];
|
|
4165
4396
|
const isNFTtransferred = bits[64 + 64 + 32 + 32 + 32 + 6];
|
|
4166
4397
|
const isNFTwithdrawn = bits[64 + 64 + 32 + 32 + 32 + 7];
|
|
4167
|
-
const owner =
|
|
4168
|
-
const collection =
|
|
4398
|
+
const owner = import_o1js23.PublicKey.from({ x: ownerX, isOdd: ownerIsOdd });
|
|
4399
|
+
const collection = import_o1js23.PublicKey.from({
|
|
4169
4400
|
x: collectionX,
|
|
4170
4401
|
isOdd: collectionIsOdd
|
|
4171
4402
|
});
|
|
4172
|
-
const nft =
|
|
4173
|
-
const auctioneer =
|
|
4403
|
+
const nft = import_o1js23.PublicKey.from({ x: nftX, isOdd: nftIsOdd });
|
|
4404
|
+
const auctioneer = import_o1js23.PublicKey.from({
|
|
4174
4405
|
x: auctioneerX,
|
|
4175
4406
|
isOdd: auctioneerIsOdd
|
|
4176
4407
|
});
|
|
4177
|
-
const bidder =
|
|
4408
|
+
const bidder = import_o1js23.PublicKey.from({
|
|
4178
4409
|
x: bidderX,
|
|
4179
4410
|
isOdd: bidderIsOdd
|
|
4180
4411
|
});
|
|
4181
|
-
const minimumPrice =
|
|
4182
|
-
const transferFee =
|
|
4183
|
-
const saleFee =
|
|
4184
|
-
const auctionEndTime =
|
|
4185
|
-
const withdrawPeriod =
|
|
4412
|
+
const minimumPrice = import_o1js23.UInt64.Unsafe.fromField(import_o1js23.Field.fromBits(bits.slice(0, 64)));
|
|
4413
|
+
const transferFee = import_o1js23.UInt64.Unsafe.fromField(import_o1js23.Field.fromBits(bits.slice(64, 64 + 64)));
|
|
4414
|
+
const saleFee = import_o1js23.UInt32.Unsafe.fromField(import_o1js23.Field.fromBits(bits.slice(64 + 64, 64 + 64 + 32)));
|
|
4415
|
+
const auctionEndTime = import_o1js23.UInt32.Unsafe.fromField(import_o1js23.Field.fromBits(bits.slice(64 + 64 + 32, 64 + 64 + 32 + 32)));
|
|
4416
|
+
const withdrawPeriod = import_o1js23.UInt32.Unsafe.fromField(import_o1js23.Field.fromBits(bits.slice(64 + 64 + 32 + 32, 64 + 64 + 32 + 32 + 32)));
|
|
4186
4417
|
return new _Auction({
|
|
4187
4418
|
owner,
|
|
4188
4419
|
collection,
|
|
@@ -4200,37 +4431,37 @@ var Auction = class _Auction extends (0, import_o1js21.Struct)({
|
|
|
4200
4431
|
});
|
|
4201
4432
|
}
|
|
4202
4433
|
};
|
|
4203
|
-
var AuctionState = class extends (0,
|
|
4204
|
-
bidAmount:
|
|
4434
|
+
var AuctionState = class extends (0, import_o1js23.Struct)({
|
|
4435
|
+
bidAmount: import_o1js23.UInt64,
|
|
4205
4436
|
auction: Auction,
|
|
4206
|
-
settled:
|
|
4437
|
+
settled: import_o1js23.Bool
|
|
4207
4438
|
}) {
|
|
4208
4439
|
};
|
|
4209
|
-
var AuctionBidEvent = class extends (0,
|
|
4210
|
-
bidder:
|
|
4211
|
-
price:
|
|
4440
|
+
var AuctionBidEvent = class extends (0, import_o1js23.Struct)({
|
|
4441
|
+
bidder: import_o1js23.PublicKey,
|
|
4442
|
+
price: import_o1js23.UInt64
|
|
4212
4443
|
}) {
|
|
4213
4444
|
};
|
|
4214
4445
|
function AuctionFactory(params) {
|
|
4215
4446
|
const { collectionContract } = params;
|
|
4216
|
-
class NonFungibleTokenAuctionContract extends
|
|
4447
|
+
class NonFungibleTokenAuctionContract extends import_o1js23.SmartContract {
|
|
4217
4448
|
constructor() {
|
|
4218
4449
|
super(...arguments);
|
|
4219
|
-
this.auctionData = (0,
|
|
4220
|
-
this.bidAmount = (0,
|
|
4221
|
-
this.settled = (0,
|
|
4450
|
+
this.auctionData = (0, import_o1js23.State)();
|
|
4451
|
+
this.bidAmount = (0, import_o1js23.State)(import_o1js23.UInt64.zero);
|
|
4452
|
+
this.settled = (0, import_o1js23.State)((0, import_o1js23.Bool)(false));
|
|
4222
4453
|
this.events = {
|
|
4223
4454
|
bid: AuctionBidEvent,
|
|
4224
4455
|
settleAuction: TransferParams,
|
|
4225
4456
|
canTransfer: TransferEvent,
|
|
4226
|
-
settlePayment:
|
|
4227
|
-
settleAuctioneerPayment:
|
|
4228
|
-
withdraw:
|
|
4457
|
+
settlePayment: import_o1js23.UInt64,
|
|
4458
|
+
settleAuctioneerPayment: import_o1js23.UInt64,
|
|
4459
|
+
withdraw: import_o1js23.UInt64
|
|
4229
4460
|
};
|
|
4230
4461
|
}
|
|
4231
4462
|
async deploy(args) {
|
|
4232
4463
|
await super.deploy(args);
|
|
4233
|
-
(0,
|
|
4464
|
+
(0, import_o1js23.assert)(args.saleFee.lessThanOrEqual(import_o1js23.UInt32.from(MAX_SALE_FEE)), "Sale fee is too high");
|
|
4234
4465
|
this.auctionData.set(new Auction({
|
|
4235
4466
|
owner: args.owner,
|
|
4236
4467
|
collection: args.collection,
|
|
@@ -4241,18 +4472,18 @@ function AuctionFactory(params) {
|
|
|
4241
4472
|
saleFee: args.saleFee,
|
|
4242
4473
|
auctionEndTime: args.auctionEndTime,
|
|
4243
4474
|
withdrawPeriod: args.withdrawPeriod,
|
|
4244
|
-
bidder:
|
|
4245
|
-
isOwnerPaid: (0,
|
|
4246
|
-
isNFTtransferred: (0,
|
|
4247
|
-
isNFTwithdrawn: (0,
|
|
4475
|
+
bidder: import_o1js23.PublicKey.empty(),
|
|
4476
|
+
isOwnerPaid: (0, import_o1js23.Bool)(false),
|
|
4477
|
+
isNFTtransferred: (0, import_o1js23.Bool)(false),
|
|
4478
|
+
isNFTwithdrawn: (0, import_o1js23.Bool)(false)
|
|
4248
4479
|
}).pack());
|
|
4249
|
-
this.settled.set((0,
|
|
4250
|
-
this.bidAmount.set(
|
|
4480
|
+
this.settled.set((0, import_o1js23.Bool)(false));
|
|
4481
|
+
this.bidAmount.set(import_o1js23.UInt64.zero);
|
|
4251
4482
|
this.account.permissions.set({
|
|
4252
|
-
...
|
|
4253
|
-
send:
|
|
4254
|
-
setVerificationKey:
|
|
4255
|
-
setPermissions:
|
|
4483
|
+
...import_o1js23.Permissions.default(),
|
|
4484
|
+
send: import_o1js23.Permissions.proof(),
|
|
4485
|
+
setVerificationKey: import_o1js23.Permissions.VerificationKey.impossibleDuringCurrentVersion(),
|
|
4486
|
+
setPermissions: import_o1js23.Permissions.impossible()
|
|
4256
4487
|
});
|
|
4257
4488
|
}
|
|
4258
4489
|
getCollectionContract(address) {
|
|
@@ -4261,24 +4492,32 @@ function AuctionFactory(params) {
|
|
|
4261
4492
|
}
|
|
4262
4493
|
calculateSaleFee(params2) {
|
|
4263
4494
|
const { price, saleFee, transferFee } = params2;
|
|
4264
|
-
saleFee.assertLessThanOrEqual(
|
|
4265
|
-
return
|
|
4495
|
+
saleFee.assertLessThanOrEqual(import_o1js23.UInt32.from(MAX_SALE_FEE), "Sale fee is too high");
|
|
4496
|
+
return mulDiv({
|
|
4497
|
+
value: price,
|
|
4498
|
+
multiplier: import_o1js23.UInt64.from(saleFee),
|
|
4499
|
+
denominator: import_o1js23.UInt64.from(MAX_SALE_FEE)
|
|
4500
|
+
}).result;
|
|
4266
4501
|
}
|
|
4267
4502
|
// anyone can call this method to bid, paying the bid amount for the bidder
|
|
4268
4503
|
async bid(price, bidder) {
|
|
4269
4504
|
const settled = this.settled.getAndRequireEquals();
|
|
4270
4505
|
settled.assertFalse("Auction already finished");
|
|
4271
4506
|
const bidAmount = this.bidAmount.getAndRequireEquals();
|
|
4272
|
-
this.account.balance.requireBetween(bidAmount,
|
|
4507
|
+
this.account.balance.requireBetween(bidAmount, import_o1js23.UInt64.MAXINT());
|
|
4273
4508
|
const auction = Auction.unpack(this.auctionData.getAndRequireEquals());
|
|
4274
4509
|
price.assertGreaterThanOrEqual(auction.minimumPrice, "Bid should be greater or equal than the minimum price");
|
|
4275
|
-
price.assertGreaterThan(bidAmount.add(
|
|
4276
|
-
|
|
4510
|
+
price.assertGreaterThan(bidAmount.add(mulDiv({
|
|
4511
|
+
value: bidAmount,
|
|
4512
|
+
multiplier: import_o1js23.UInt64.from(MIN_STEP),
|
|
4513
|
+
denominator: import_o1js23.UInt64.from(1e3)
|
|
4514
|
+
}).result), "Bid should be greater than the existing bid plus the minimum step");
|
|
4515
|
+
this.network.globalSlotSinceGenesis.requireBetween(import_o1js23.UInt32.from(0), auction.auctionEndTime);
|
|
4277
4516
|
const sender = this.sender.getUnconstrained();
|
|
4278
|
-
const senderUpdate =
|
|
4279
|
-
const returnUpdate =
|
|
4280
|
-
senderUpdate.body.useFullCommitment = (0,
|
|
4281
|
-
returnUpdate.body.useFullCommitment = (0,
|
|
4517
|
+
const senderUpdate = import_o1js23.AccountUpdate.createSigned(sender);
|
|
4518
|
+
const returnUpdate = import_o1js23.AccountUpdate.create(auction.bidder);
|
|
4519
|
+
senderUpdate.body.useFullCommitment = (0, import_o1js23.Bool)(true);
|
|
4520
|
+
returnUpdate.body.useFullCommitment = (0, import_o1js23.Bool)(true);
|
|
4282
4521
|
this.balance.subInPlace(bidAmount);
|
|
4283
4522
|
returnUpdate.balance.addInPlace(bidAmount);
|
|
4284
4523
|
senderUpdate.balance.subInPlace(price);
|
|
@@ -4304,12 +4543,12 @@ function AuctionFactory(params) {
|
|
|
4304
4543
|
async settleAuction() {
|
|
4305
4544
|
const settled = this.settled.getAndRequireEquals();
|
|
4306
4545
|
settled.assertFalse("Auction already settled");
|
|
4307
|
-
this.settled.set((0,
|
|
4546
|
+
this.settled.set((0, import_o1js23.Bool)(true));
|
|
4308
4547
|
const auction = Auction.unpack(this.auctionData.getAndRequireEquals());
|
|
4309
|
-
this.network.globalSlotSinceGenesis.requireBetween(auction.auctionEndTime.add(1),
|
|
4548
|
+
this.network.globalSlotSinceGenesis.requireBetween(auction.auctionEndTime.add(1), import_o1js23.UInt32.MAXINT());
|
|
4310
4549
|
const nftAddress = auction.nft;
|
|
4311
4550
|
const bidAmount = this.bidAmount.getAndRequireEquals();
|
|
4312
|
-
auction.bidder.equals(
|
|
4551
|
+
auction.bidder.equals(import_o1js23.PublicKey.empty()).assertFalse("No bidder");
|
|
4313
4552
|
bidAmount.assertGreaterThanOrEqual(auction.minimumPrice, "Bidder does not have enough balance");
|
|
4314
4553
|
const collection = this.getCollectionContract(auction.collection);
|
|
4315
4554
|
const transferParams = new TransferParams({
|
|
@@ -4318,7 +4557,7 @@ function AuctionFactory(params) {
|
|
|
4318
4557
|
to: auction.bidder,
|
|
4319
4558
|
price: UInt64Option.fromValue(bidAmount),
|
|
4320
4559
|
context: new NFTTransactionContext({
|
|
4321
|
-
custom: [(0,
|
|
4560
|
+
custom: [(0, import_o1js23.Field)(1), (0, import_o1js23.Field)(0), (0, import_o1js23.Field)(0)]
|
|
4322
4561
|
})
|
|
4323
4562
|
});
|
|
4324
4563
|
await collection.transferByProof(transferParams);
|
|
@@ -4329,11 +4568,11 @@ function AuctionFactory(params) {
|
|
|
4329
4568
|
async withdrawNFT() {
|
|
4330
4569
|
const settled = this.settled.getAndRequireEquals();
|
|
4331
4570
|
settled.assertFalse("Auction already settled");
|
|
4332
|
-
this.settled.set((0,
|
|
4571
|
+
this.settled.set((0, import_o1js23.Bool)(true));
|
|
4333
4572
|
const auction = Auction.unpack(this.auctionData.getAndRequireEquals());
|
|
4334
4573
|
auction.isNFTwithdrawn.assertFalse("NFT already withdrawn");
|
|
4335
4574
|
auction.isNFTtransferred.assertFalse("NFT already transferred");
|
|
4336
|
-
this.network.globalSlotSinceGenesis.requireBetween(auction.auctionEndTime.add(auction.withdrawPeriod),
|
|
4575
|
+
this.network.globalSlotSinceGenesis.requireBetween(auction.auctionEndTime.add(auction.withdrawPeriod), import_o1js23.UInt32.MAXINT());
|
|
4337
4576
|
const nftAddress = auction.nft;
|
|
4338
4577
|
const collection = this.getCollectionContract(auction.collection);
|
|
4339
4578
|
const transferParams = new TransferParams({
|
|
@@ -4342,16 +4581,16 @@ function AuctionFactory(params) {
|
|
|
4342
4581
|
to: auction.owner,
|
|
4343
4582
|
price: UInt64Option.none(),
|
|
4344
4583
|
context: new NFTTransactionContext({
|
|
4345
|
-
custom: [(0,
|
|
4584
|
+
custom: [(0, import_o1js23.Field)(2), (0, import_o1js23.Field)(0), (0, import_o1js23.Field)(0)]
|
|
4346
4585
|
})
|
|
4347
4586
|
});
|
|
4348
4587
|
await collection.transferByProof(transferParams);
|
|
4349
4588
|
this.emitEvent("settleAuction", transferParams);
|
|
4350
4589
|
}
|
|
4351
4590
|
async canTransfer(params2) {
|
|
4352
|
-
this.settled.requireEquals((0,
|
|
4353
|
-
const isSale = params2.context.custom[0].equals((0,
|
|
4354
|
-
const isWithdraw = params2.context.custom[0].equals((0,
|
|
4591
|
+
this.settled.requireEquals((0, import_o1js23.Bool)(true));
|
|
4592
|
+
const isSale = params2.context.custom[0].equals((0, import_o1js23.Field)(1));
|
|
4593
|
+
const isWithdraw = params2.context.custom[0].equals((0, import_o1js23.Field)(2));
|
|
4355
4594
|
isSale.or(isWithdraw).assertTrue("Invalid context");
|
|
4356
4595
|
const auction = Auction.unpack(this.auctionData.getAndRequireEquals());
|
|
4357
4596
|
auction.isNFTtransferred.assertFalse("NFT already transferred");
|
|
@@ -4361,29 +4600,29 @@ function AuctionFactory(params) {
|
|
|
4361
4600
|
const owner = auction.owner;
|
|
4362
4601
|
const bidder = auction.bidder;
|
|
4363
4602
|
const bidAmount = this.bidAmount.getAndRequireEquals();
|
|
4364
|
-
this.network.globalSlotSinceGenesis.requireBetween(auction.auctionEndTime.add(
|
|
4603
|
+
this.network.globalSlotSinceGenesis.requireBetween(auction.auctionEndTime.add(import_o1js23.Provable.if(isSale, import_o1js23.UInt32.from(1), auction.withdrawPeriod)), import_o1js23.UInt32.MAXINT());
|
|
4365
4604
|
params2.collection.assertEquals(collectionAddress);
|
|
4366
4605
|
params2.nft.assertEquals(nftAddress);
|
|
4367
|
-
params2.from.equals(owner).and(params2.approved.equals(this.address)).or(params2.from.equals(this.address).and(params2.approved.equals(
|
|
4606
|
+
params2.from.equals(owner).and(params2.approved.equals(this.address)).or(params2.from.equals(this.address).and(params2.approved.equals(import_o1js23.PublicKey.empty()))).assertTrue("Only owner or auction can transfer");
|
|
4368
4607
|
params2.price.isSome.assertEquals(isSale);
|
|
4369
|
-
params2.price.orElse(
|
|
4370
|
-
params2.price.orElse(
|
|
4371
|
-
params2.to.assertEquals(
|
|
4372
|
-
const fee = params2.fee.orElse(
|
|
4373
|
-
fee.assertLessThanOrEqual(
|
|
4608
|
+
params2.price.orElse(import_o1js23.UInt64.zero).assertEquals(import_o1js23.Provable.if(isSale, bidAmount, import_o1js23.UInt64.zero));
|
|
4609
|
+
params2.price.orElse(import_o1js23.UInt64.MAXINT()).assertGreaterThanOrEqual(auction.minimumPrice, "Bid should be greater or equal than the minimum price");
|
|
4610
|
+
params2.to.assertEquals(import_o1js23.Provable.if(isSale, bidder, auction.owner));
|
|
4611
|
+
const fee = params2.fee.orElse(import_o1js23.UInt64.zero);
|
|
4612
|
+
fee.assertLessThanOrEqual(import_o1js23.Provable.if(isSale, bidAmount, import_o1js23.UInt64.MAXINT()), "Fee is higher than the bid");
|
|
4374
4613
|
const saleFee = this.calculateSaleFee({
|
|
4375
4614
|
price: bidAmount,
|
|
4376
4615
|
saleFee: auction.saleFee,
|
|
4377
4616
|
transferFee: auction.transferFee
|
|
4378
4617
|
});
|
|
4379
|
-
fee.assertLessThanOrEqual(
|
|
4618
|
+
fee.assertLessThanOrEqual(import_o1js23.Provable.if(isSale, saleFee, import_o1js23.UInt64.MAXINT()), "Fee is higher than the sale fee");
|
|
4380
4619
|
auction.isNFTtransferred = isSale;
|
|
4381
4620
|
auction.isNFTwithdrawn = isWithdraw;
|
|
4382
4621
|
this.auctionData.set(auction.pack());
|
|
4383
4622
|
this.emitEvent("canTransfer", new TransferEvent({
|
|
4384
4623
|
...params2
|
|
4385
4624
|
}));
|
|
4386
|
-
return (0,
|
|
4625
|
+
return (0, import_o1js23.Bool)(true);
|
|
4387
4626
|
}
|
|
4388
4627
|
async settlePayment() {
|
|
4389
4628
|
this.settled.getAndRequireEquals().assertTrue("Auction not settled");
|
|
@@ -4391,18 +4630,18 @@ function AuctionFactory(params) {
|
|
|
4391
4630
|
auction.isOwnerPaid.assertFalse("Owner is not paid yet");
|
|
4392
4631
|
auction.isNFTtransferred.assertTrue("NFT not transferred");
|
|
4393
4632
|
const bidAmount = this.bidAmount.getAndRequireEquals();
|
|
4394
|
-
this.network.globalSlotSinceGenesis.requireBetween(auction.auctionEndTime.add(1),
|
|
4633
|
+
this.network.globalSlotSinceGenesis.requireBetween(auction.auctionEndTime.add(1), import_o1js23.UInt32.MAXINT());
|
|
4395
4634
|
const payment = bidAmount.sub(this.calculateSaleFee({
|
|
4396
4635
|
price: bidAmount,
|
|
4397
4636
|
saleFee: auction.saleFee,
|
|
4398
4637
|
transferFee: auction.transferFee
|
|
4399
4638
|
}));
|
|
4400
|
-
this.account.balance.requireBetween(payment,
|
|
4401
|
-
const ownerUpdate =
|
|
4639
|
+
this.account.balance.requireBetween(payment, import_o1js23.UInt64.MAXINT());
|
|
4640
|
+
const ownerUpdate = import_o1js23.AccountUpdate.create(auction.owner);
|
|
4402
4641
|
ownerUpdate.balance.addInPlace(payment);
|
|
4403
4642
|
this.balance.subInPlace(payment);
|
|
4404
|
-
ownerUpdate.body.useFullCommitment = (0,
|
|
4405
|
-
auction.isOwnerPaid = (0,
|
|
4643
|
+
ownerUpdate.body.useFullCommitment = (0, import_o1js23.Bool)(true);
|
|
4644
|
+
auction.isOwnerPaid = (0, import_o1js23.Bool)(true);
|
|
4406
4645
|
this.auctionData.set(auction.pack());
|
|
4407
4646
|
this.emitEvent("settlePayment", payment);
|
|
4408
4647
|
}
|
|
@@ -4415,12 +4654,12 @@ function AuctionFactory(params) {
|
|
|
4415
4654
|
this.settled.getAndRequireEquals().assertTrue("Auction not settled");
|
|
4416
4655
|
const auction = Auction.unpack(this.auctionData.getAndRequireEquals());
|
|
4417
4656
|
auction.isOwnerPaid.assertTrue("Owner is not paid yet, first call settlePayment");
|
|
4418
|
-
this.network.globalSlotSinceGenesis.requireBetween(auction.auctionEndTime.add(1),
|
|
4419
|
-
this.account.balance.requireBetween(amount,
|
|
4420
|
-
const auctioneerUpdate =
|
|
4657
|
+
this.network.globalSlotSinceGenesis.requireBetween(auction.auctionEndTime.add(1), import_o1js23.UInt32.MAXINT());
|
|
4658
|
+
this.account.balance.requireBetween(amount, import_o1js23.UInt64.MAXINT());
|
|
4659
|
+
const auctioneerUpdate = import_o1js23.AccountUpdate.create(auction.auctioneer);
|
|
4421
4660
|
auctioneerUpdate.balance.addInPlace(amount);
|
|
4422
4661
|
this.balance.subInPlace(amount);
|
|
4423
|
-
auctioneerUpdate.body.useFullCommitment = (0,
|
|
4662
|
+
auctioneerUpdate.body.useFullCommitment = (0, import_o1js23.Bool)(true);
|
|
4424
4663
|
this.emitEvent("settleAuctioneerPayment", amount);
|
|
4425
4664
|
}
|
|
4426
4665
|
/**
|
|
@@ -4432,72 +4671,72 @@ function AuctionFactory(params) {
|
|
|
4432
4671
|
async withdraw() {
|
|
4433
4672
|
const auction = Auction.unpack(this.auctionData.getAndRequireEquals());
|
|
4434
4673
|
auction.isNFTtransferred.assertFalse("NFT already transferred");
|
|
4435
|
-
this.network.globalSlotSinceGenesis.requireBetween(auction.auctionEndTime.add(auction.withdrawPeriod),
|
|
4674
|
+
this.network.globalSlotSinceGenesis.requireBetween(auction.auctionEndTime.add(auction.withdrawPeriod), import_o1js23.UInt32.MAXINT());
|
|
4436
4675
|
const bidAmount = this.bidAmount.getAndRequireEquals();
|
|
4437
|
-
const bidderUpdate =
|
|
4676
|
+
const bidderUpdate = import_o1js23.AccountUpdate.create(auction.bidder);
|
|
4438
4677
|
bidderUpdate.balance.addInPlace(bidAmount);
|
|
4439
4678
|
this.balance.subInPlace(bidAmount);
|
|
4440
|
-
bidderUpdate.body.useFullCommitment = (0,
|
|
4441
|
-
this.settled.set((0,
|
|
4679
|
+
bidderUpdate.body.useFullCommitment = (0, import_o1js23.Bool)(true);
|
|
4680
|
+
this.settled.set((0, import_o1js23.Bool)(true));
|
|
4442
4681
|
this.emitEvent("withdraw", bidAmount);
|
|
4443
4682
|
}
|
|
4444
4683
|
}
|
|
4445
4684
|
(0, import_tslib10.__decorate)([
|
|
4446
|
-
(0,
|
|
4685
|
+
(0, import_o1js23.state)(AuctionPacked),
|
|
4447
4686
|
(0, import_tslib10.__metadata)("design:type", Object)
|
|
4448
4687
|
], NonFungibleTokenAuctionContract.prototype, "auctionData", void 0);
|
|
4449
4688
|
(0, import_tslib10.__decorate)([
|
|
4450
|
-
(0,
|
|
4689
|
+
(0, import_o1js23.state)(import_o1js23.UInt64),
|
|
4451
4690
|
(0, import_tslib10.__metadata)("design:type", Object)
|
|
4452
4691
|
], NonFungibleTokenAuctionContract.prototype, "bidAmount", void 0);
|
|
4453
4692
|
(0, import_tslib10.__decorate)([
|
|
4454
|
-
(0,
|
|
4693
|
+
(0, import_o1js23.state)(import_o1js23.Bool),
|
|
4455
4694
|
(0, import_tslib10.__metadata)("design:type", Object)
|
|
4456
4695
|
], NonFungibleTokenAuctionContract.prototype, "settled", void 0);
|
|
4457
4696
|
(0, import_tslib10.__decorate)([
|
|
4458
|
-
|
|
4697
|
+
import_o1js23.method.returns(Auction),
|
|
4459
4698
|
(0, import_tslib10.__metadata)("design:type", Function),
|
|
4460
|
-
(0, import_tslib10.__metadata)("design:paramtypes", [
|
|
4699
|
+
(0, import_tslib10.__metadata)("design:paramtypes", [import_o1js23.UInt64, import_o1js23.PublicKey]),
|
|
4461
4700
|
(0, import_tslib10.__metadata)("design:returntype", Promise)
|
|
4462
4701
|
], NonFungibleTokenAuctionContract.prototype, "bid", null);
|
|
4463
4702
|
(0, import_tslib10.__decorate)([
|
|
4464
|
-
|
|
4703
|
+
import_o1js23.method.returns(AuctionState),
|
|
4465
4704
|
(0, import_tslib10.__metadata)("design:type", Function),
|
|
4466
4705
|
(0, import_tslib10.__metadata)("design:paramtypes", []),
|
|
4467
4706
|
(0, import_tslib10.__metadata)("design:returntype", Promise)
|
|
4468
4707
|
], NonFungibleTokenAuctionContract.prototype, "getAuctionState", null);
|
|
4469
4708
|
(0, import_tslib10.__decorate)([
|
|
4470
|
-
|
|
4709
|
+
import_o1js23.method,
|
|
4471
4710
|
(0, import_tslib10.__metadata)("design:type", Function),
|
|
4472
4711
|
(0, import_tslib10.__metadata)("design:paramtypes", []),
|
|
4473
4712
|
(0, import_tslib10.__metadata)("design:returntype", Promise)
|
|
4474
4713
|
], NonFungibleTokenAuctionContract.prototype, "settleAuction", null);
|
|
4475
4714
|
(0, import_tslib10.__decorate)([
|
|
4476
|
-
|
|
4715
|
+
import_o1js23.method,
|
|
4477
4716
|
(0, import_tslib10.__metadata)("design:type", Function),
|
|
4478
4717
|
(0, import_tslib10.__metadata)("design:paramtypes", []),
|
|
4479
4718
|
(0, import_tslib10.__metadata)("design:returntype", Promise)
|
|
4480
4719
|
], NonFungibleTokenAuctionContract.prototype, "withdrawNFT", null);
|
|
4481
4720
|
(0, import_tslib10.__decorate)([
|
|
4482
|
-
|
|
4721
|
+
import_o1js23.method.returns(import_o1js23.Bool),
|
|
4483
4722
|
(0, import_tslib10.__metadata)("design:type", Function),
|
|
4484
4723
|
(0, import_tslib10.__metadata)("design:paramtypes", [TransferExtendedParams]),
|
|
4485
4724
|
(0, import_tslib10.__metadata)("design:returntype", Promise)
|
|
4486
4725
|
], NonFungibleTokenAuctionContract.prototype, "canTransfer", null);
|
|
4487
4726
|
(0, import_tslib10.__decorate)([
|
|
4488
|
-
|
|
4727
|
+
import_o1js23.method,
|
|
4489
4728
|
(0, import_tslib10.__metadata)("design:type", Function),
|
|
4490
4729
|
(0, import_tslib10.__metadata)("design:paramtypes", []),
|
|
4491
4730
|
(0, import_tslib10.__metadata)("design:returntype", Promise)
|
|
4492
4731
|
], NonFungibleTokenAuctionContract.prototype, "settlePayment", null);
|
|
4493
4732
|
(0, import_tslib10.__decorate)([
|
|
4494
|
-
|
|
4733
|
+
import_o1js23.method,
|
|
4495
4734
|
(0, import_tslib10.__metadata)("design:type", Function),
|
|
4496
|
-
(0, import_tslib10.__metadata)("design:paramtypes", [
|
|
4735
|
+
(0, import_tslib10.__metadata)("design:paramtypes", [import_o1js23.UInt64]),
|
|
4497
4736
|
(0, import_tslib10.__metadata)("design:returntype", Promise)
|
|
4498
4737
|
], NonFungibleTokenAuctionContract.prototype, "settleAuctioneerPayment", null);
|
|
4499
4738
|
(0, import_tslib10.__decorate)([
|
|
4500
|
-
|
|
4739
|
+
import_o1js23.method,
|
|
4501
4740
|
(0, import_tslib10.__metadata)("design:type", Function),
|
|
4502
4741
|
(0, import_tslib10.__metadata)("design:paramtypes", []),
|
|
4503
4742
|
(0, import_tslib10.__metadata)("design:returntype", Promise)
|
|
@@ -4507,28 +4746,28 @@ function AuctionFactory(params) {
|
|
|
4507
4746
|
|
|
4508
4747
|
// dist/node/marketplace/nft-shares.js
|
|
4509
4748
|
var import_tslib11 = require("tslib");
|
|
4510
|
-
var
|
|
4749
|
+
var import_o1js24 = require("o1js");
|
|
4511
4750
|
var import_token = require("@silvana-one/token");
|
|
4512
|
-
var NFTSharesDataPacked = class extends (0,
|
|
4513
|
-
adminX:
|
|
4514
|
-
ownerX:
|
|
4515
|
-
collectionX:
|
|
4516
|
-
nftX:
|
|
4517
|
-
auctionX:
|
|
4518
|
-
data:
|
|
4751
|
+
var NFTSharesDataPacked = class extends (0, import_o1js24.Struct)({
|
|
4752
|
+
adminX: import_o1js24.Field,
|
|
4753
|
+
ownerX: import_o1js24.Field,
|
|
4754
|
+
collectionX: import_o1js24.Field,
|
|
4755
|
+
nftX: import_o1js24.Field,
|
|
4756
|
+
auctionX: import_o1js24.Field,
|
|
4757
|
+
data: import_o1js24.Field
|
|
4519
4758
|
}) {
|
|
4520
4759
|
};
|
|
4521
|
-
var NFTSharesData = class _NFTSharesData extends (0,
|
|
4522
|
-
admin:
|
|
4523
|
-
owner:
|
|
4524
|
-
collection:
|
|
4525
|
-
nft:
|
|
4526
|
-
auction:
|
|
4527
|
-
maxBuyPrice:
|
|
4528
|
-
minSellPrice:
|
|
4760
|
+
var NFTSharesData = class _NFTSharesData extends (0, import_o1js24.Struct)({
|
|
4761
|
+
admin: import_o1js24.PublicKey,
|
|
4762
|
+
owner: import_o1js24.PublicKey,
|
|
4763
|
+
collection: import_o1js24.PublicKey,
|
|
4764
|
+
nft: import_o1js24.PublicKey,
|
|
4765
|
+
auction: import_o1js24.PublicKey,
|
|
4766
|
+
maxBuyPrice: import_o1js24.UInt64,
|
|
4767
|
+
minSellPrice: import_o1js24.UInt64
|
|
4529
4768
|
}) {
|
|
4530
4769
|
pack() {
|
|
4531
|
-
const data =
|
|
4770
|
+
const data = import_o1js24.Field.fromBits([
|
|
4532
4771
|
...this.maxBuyPrice.value.toBits(64),
|
|
4533
4772
|
...this.minSellPrice.value.toBits(64),
|
|
4534
4773
|
this.admin.isOdd,
|
|
@@ -4558,16 +4797,16 @@ var NFTSharesData = class _NFTSharesData extends (0, import_o1js22.Struct)({
|
|
|
4558
4797
|
const collectionX = packed.collectionX;
|
|
4559
4798
|
const nftX = packed.nftX;
|
|
4560
4799
|
const auctionX = packed.auctionX;
|
|
4561
|
-
const admin =
|
|
4562
|
-
const owner =
|
|
4563
|
-
const collection =
|
|
4800
|
+
const admin = import_o1js24.PublicKey.from({ x: adminX, isOdd: adminIsOdd });
|
|
4801
|
+
const owner = import_o1js24.PublicKey.from({ x: ownerX, isOdd: ownerIsOdd });
|
|
4802
|
+
const collection = import_o1js24.PublicKey.from({
|
|
4564
4803
|
x: collectionX,
|
|
4565
4804
|
isOdd: collectionIsOdd
|
|
4566
4805
|
});
|
|
4567
|
-
const nft =
|
|
4568
|
-
const auction =
|
|
4569
|
-
const maxBuyPrice =
|
|
4570
|
-
const minSellPrice =
|
|
4806
|
+
const nft = import_o1js24.PublicKey.from({ x: nftX, isOdd: nftIsOdd });
|
|
4807
|
+
const auction = import_o1js24.PublicKey.from({ x: auctionX, isOdd: auctionIsOdd });
|
|
4808
|
+
const maxBuyPrice = import_o1js24.UInt64.Unsafe.fromField(import_o1js24.Field.fromBits(bits.slice(0, 64)));
|
|
4809
|
+
const minSellPrice = import_o1js24.UInt64.Unsafe.fromField(import_o1js24.Field.fromBits(bits.slice(64, 64 + 64)));
|
|
4571
4810
|
return new _NFTSharesData({
|
|
4572
4811
|
admin,
|
|
4573
4812
|
owner,
|
|
@@ -4581,20 +4820,20 @@ var NFTSharesData = class _NFTSharesData extends (0, import_o1js22.Struct)({
|
|
|
4581
4820
|
};
|
|
4582
4821
|
function NFTSharesFactory(params) {
|
|
4583
4822
|
const { auctionContract } = params;
|
|
4584
|
-
class NFTSharesAdmin extends
|
|
4823
|
+
class NFTSharesAdmin extends import_o1js24.SmartContract {
|
|
4585
4824
|
constructor() {
|
|
4586
4825
|
super(...arguments);
|
|
4587
|
-
this.admin = (0,
|
|
4588
|
-
this.owner = (0,
|
|
4826
|
+
this.admin = (0, import_o1js24.State)();
|
|
4827
|
+
this.owner = (0, import_o1js24.State)();
|
|
4589
4828
|
}
|
|
4590
4829
|
async deploy(props) {
|
|
4591
4830
|
await super.deploy(props);
|
|
4592
4831
|
this.admin.set(props.admin);
|
|
4593
4832
|
this.owner.set(props.owner);
|
|
4594
4833
|
this.account.permissions.set({
|
|
4595
|
-
...
|
|
4596
|
-
setVerificationKey:
|
|
4597
|
-
setPermissions:
|
|
4834
|
+
...import_o1js24.Permissions.default(),
|
|
4835
|
+
setVerificationKey: import_o1js24.Permissions.VerificationKey.proofDuringCurrentVersion(),
|
|
4836
|
+
setPermissions: import_o1js24.Permissions.impossible()
|
|
4598
4837
|
});
|
|
4599
4838
|
}
|
|
4600
4839
|
async updateVerificationKey(vk) {
|
|
@@ -4603,7 +4842,7 @@ function NFTSharesFactory(params) {
|
|
|
4603
4842
|
}
|
|
4604
4843
|
ensureAdminSignature() {
|
|
4605
4844
|
const admin = this.admin.getAndRequireEquals();
|
|
4606
|
-
return
|
|
4845
|
+
return import_o1js24.AccountUpdate.createSigned(admin);
|
|
4607
4846
|
}
|
|
4608
4847
|
getOwner() {
|
|
4609
4848
|
return new NFTSharesOwner(this.owner.getAndRequireEquals());
|
|
@@ -4614,72 +4853,72 @@ function NFTSharesFactory(params) {
|
|
|
4614
4853
|
}
|
|
4615
4854
|
async canChangeAdmin(_admin) {
|
|
4616
4855
|
this.ensureAdminSignature();
|
|
4617
|
-
return (0,
|
|
4856
|
+
return (0, import_o1js24.Bool)(true);
|
|
4618
4857
|
}
|
|
4619
4858
|
async canPause() {
|
|
4620
4859
|
this.ensureAdminSignature();
|
|
4621
|
-
return (0,
|
|
4860
|
+
return (0, import_o1js24.Bool)(true);
|
|
4622
4861
|
}
|
|
4623
4862
|
async canResume() {
|
|
4624
4863
|
this.ensureAdminSignature();
|
|
4625
|
-
return (0,
|
|
4864
|
+
return (0, import_o1js24.Bool)(true);
|
|
4626
4865
|
}
|
|
4627
4866
|
async canChangeVerificationKey(_vk) {
|
|
4628
4867
|
this.ensureAdminSignature();
|
|
4629
|
-
return (0,
|
|
4868
|
+
return (0, import_o1js24.Bool)(true);
|
|
4630
4869
|
}
|
|
4631
4870
|
}
|
|
4632
4871
|
(0, import_tslib11.__decorate)([
|
|
4633
|
-
(0,
|
|
4872
|
+
(0, import_o1js24.state)(import_o1js24.PublicKey),
|
|
4634
4873
|
(0, import_tslib11.__metadata)("design:type", Object)
|
|
4635
4874
|
], NFTSharesAdmin.prototype, "admin", void 0);
|
|
4636
4875
|
(0, import_tslib11.__decorate)([
|
|
4637
|
-
(0,
|
|
4876
|
+
(0, import_o1js24.state)(import_o1js24.PublicKey),
|
|
4638
4877
|
(0, import_tslib11.__metadata)("design:type", Object)
|
|
4639
4878
|
], NFTSharesAdmin.prototype, "owner", void 0);
|
|
4640
4879
|
(0, import_tslib11.__decorate)([
|
|
4641
|
-
|
|
4880
|
+
import_o1js24.method,
|
|
4642
4881
|
(0, import_tslib11.__metadata)("design:type", Function),
|
|
4643
|
-
(0, import_tslib11.__metadata)("design:paramtypes", [
|
|
4882
|
+
(0, import_tslib11.__metadata)("design:paramtypes", [import_o1js24.VerificationKey]),
|
|
4644
4883
|
(0, import_tslib11.__metadata)("design:returntype", Promise)
|
|
4645
4884
|
], NFTSharesAdmin.prototype, "updateVerificationKey", null);
|
|
4646
4885
|
(0, import_tslib11.__decorate)([
|
|
4647
|
-
|
|
4886
|
+
import_o1js24.method.returns(import_o1js24.Bool),
|
|
4648
4887
|
(0, import_tslib11.__metadata)("design:type", Function),
|
|
4649
|
-
(0, import_tslib11.__metadata)("design:paramtypes", [
|
|
4888
|
+
(0, import_tslib11.__metadata)("design:paramtypes", [import_o1js24.AccountUpdate]),
|
|
4650
4889
|
(0, import_tslib11.__metadata)("design:returntype", Promise)
|
|
4651
4890
|
], NFTSharesAdmin.prototype, "canMint", null);
|
|
4652
4891
|
(0, import_tslib11.__decorate)([
|
|
4653
|
-
|
|
4892
|
+
import_o1js24.method.returns(import_o1js24.Bool),
|
|
4654
4893
|
(0, import_tslib11.__metadata)("design:type", Function),
|
|
4655
|
-
(0, import_tslib11.__metadata)("design:paramtypes", [
|
|
4894
|
+
(0, import_tslib11.__metadata)("design:paramtypes", [import_o1js24.PublicKey]),
|
|
4656
4895
|
(0, import_tslib11.__metadata)("design:returntype", Promise)
|
|
4657
4896
|
], NFTSharesAdmin.prototype, "canChangeAdmin", null);
|
|
4658
4897
|
(0, import_tslib11.__decorate)([
|
|
4659
|
-
|
|
4898
|
+
import_o1js24.method.returns(import_o1js24.Bool),
|
|
4660
4899
|
(0, import_tslib11.__metadata)("design:type", Function),
|
|
4661
4900
|
(0, import_tslib11.__metadata)("design:paramtypes", []),
|
|
4662
4901
|
(0, import_tslib11.__metadata)("design:returntype", Promise)
|
|
4663
4902
|
], NFTSharesAdmin.prototype, "canPause", null);
|
|
4664
4903
|
(0, import_tslib11.__decorate)([
|
|
4665
|
-
|
|
4904
|
+
import_o1js24.method.returns(import_o1js24.Bool),
|
|
4666
4905
|
(0, import_tslib11.__metadata)("design:type", Function),
|
|
4667
4906
|
(0, import_tslib11.__metadata)("design:paramtypes", []),
|
|
4668
4907
|
(0, import_tslib11.__metadata)("design:returntype", Promise)
|
|
4669
4908
|
], NFTSharesAdmin.prototype, "canResume", null);
|
|
4670
4909
|
(0, import_tslib11.__decorate)([
|
|
4671
|
-
|
|
4910
|
+
import_o1js24.method.returns(import_o1js24.Bool),
|
|
4672
4911
|
(0, import_tslib11.__metadata)("design:type", Function),
|
|
4673
|
-
(0, import_tslib11.__metadata)("design:paramtypes", [
|
|
4912
|
+
(0, import_tslib11.__metadata)("design:paramtypes", [import_o1js24.VerificationKey]),
|
|
4674
4913
|
(0, import_tslib11.__metadata)("design:returntype", Promise)
|
|
4675
4914
|
], NFTSharesAdmin.prototype, "canChangeVerificationKey", null);
|
|
4676
4915
|
const FungibleToken = (0, import_token.FungibleTokenContract)(NFTSharesAdmin);
|
|
4677
|
-
class NFTSharesOwner extends
|
|
4916
|
+
class NFTSharesOwner extends import_o1js24.SmartContract {
|
|
4678
4917
|
constructor() {
|
|
4679
4918
|
super(...arguments);
|
|
4680
|
-
this.data = (0,
|
|
4681
|
-
this.subscriptionOpen = (0,
|
|
4682
|
-
this.sharesOutstanding = (0,
|
|
4919
|
+
this.data = (0, import_o1js24.State)();
|
|
4920
|
+
this.subscriptionOpen = (0, import_o1js24.State)((0, import_o1js24.Bool)(true));
|
|
4921
|
+
this.sharesOutstanding = (0, import_o1js24.State)(import_o1js24.UInt64.zero);
|
|
4683
4922
|
}
|
|
4684
4923
|
/**
|
|
4685
4924
|
* Deploys the contract with initial settings.
|
|
@@ -4697,14 +4936,14 @@ function NFTSharesFactory(params) {
|
|
|
4697
4936
|
minSellPrice: props.minSellPrice
|
|
4698
4937
|
}).pack());
|
|
4699
4938
|
this.account.zkappUri.set(props.uri);
|
|
4700
|
-
this.subscriptionOpen.set((0,
|
|
4701
|
-
this.sharesOutstanding.set(
|
|
4939
|
+
this.subscriptionOpen.set((0, import_o1js24.Bool)(true));
|
|
4940
|
+
this.sharesOutstanding.set(import_o1js24.UInt64.zero);
|
|
4702
4941
|
this.account.permissions.set({
|
|
4703
|
-
...
|
|
4942
|
+
...import_o1js24.Permissions.default(),
|
|
4704
4943
|
// Allow the upgrade authority to set the verification key even without a protocol upgrade,
|
|
4705
4944
|
// enabling upgrades in case of o1js breaking changes.
|
|
4706
|
-
setVerificationKey:
|
|
4707
|
-
setPermissions:
|
|
4945
|
+
setVerificationKey: import_o1js24.Permissions.VerificationKey.proofDuringCurrentVersion(),
|
|
4946
|
+
setPermissions: import_o1js24.Permissions.impossible()
|
|
4708
4947
|
});
|
|
4709
4948
|
}
|
|
4710
4949
|
/**
|
|
@@ -4713,8 +4952,8 @@ function NFTSharesFactory(params) {
|
|
|
4713
4952
|
*/
|
|
4714
4953
|
ensureOwnerSignature() {
|
|
4715
4954
|
const data = NFTSharesData.unpack(this.data.getAndRequireEquals());
|
|
4716
|
-
const adminUpdate =
|
|
4717
|
-
adminUpdate.body.useFullCommitment = (0,
|
|
4955
|
+
const adminUpdate = import_o1js24.AccountUpdate.createSigned(data.admin);
|
|
4956
|
+
adminUpdate.body.useFullCommitment = (0, import_o1js24.Bool)(true);
|
|
4718
4957
|
return data;
|
|
4719
4958
|
}
|
|
4720
4959
|
getAuction(auction) {
|
|
@@ -4729,30 +4968,32 @@ function NFTSharesFactory(params) {
|
|
|
4729
4968
|
*/
|
|
4730
4969
|
async canMint(_accountUpdate) {
|
|
4731
4970
|
const subscriptionOpen = this.subscriptionOpen.getAndRequireEquals();
|
|
4732
|
-
subscriptionOpen.assertEquals((0,
|
|
4971
|
+
subscriptionOpen.assertEquals((0, import_o1js24.Bool)(true), "Subscription is closed");
|
|
4733
4972
|
const address = _accountUpdate.publicKey;
|
|
4734
4973
|
const amount = _accountUpdate.balanceChange.magnitude;
|
|
4735
|
-
const senderUpdate =
|
|
4974
|
+
const senderUpdate = import_o1js24.AccountUpdate.createSigned(address);
|
|
4736
4975
|
senderUpdate.balance.subInPlace(amount);
|
|
4737
4976
|
this.balance.addInPlace(amount);
|
|
4738
4977
|
const sharesOutstanding = this.sharesOutstanding.getAndRequireEquals();
|
|
4739
4978
|
this.sharesOutstanding.set(sharesOutstanding.add(amount));
|
|
4740
|
-
return (0,
|
|
4979
|
+
return (0, import_o1js24.Bool)(true);
|
|
4741
4980
|
}
|
|
4742
4981
|
async withdraw(shares) {
|
|
4743
4982
|
const subscriptionOpen = this.subscriptionOpen.getAndRequireEquals();
|
|
4744
|
-
subscriptionOpen.assertEquals((0,
|
|
4983
|
+
subscriptionOpen.assertEquals((0, import_o1js24.Bool)(false), "Subscription is not closed, cannot withdraw");
|
|
4745
4984
|
const sharesOutstanding = this.sharesOutstanding.getAndRequireEquals();
|
|
4746
4985
|
const balance = this.account.balance.getAndRequireEquals();
|
|
4747
|
-
balance.equals(
|
|
4748
|
-
const
|
|
4749
|
-
|
|
4750
|
-
|
|
4986
|
+
balance.equals(import_o1js24.UInt64.zero).assertFalse("Balance is zero, nothing to withdraw");
|
|
4987
|
+
const amountInMina = mulDiv({
|
|
4988
|
+
value: shares,
|
|
4989
|
+
multiplier: balance,
|
|
4990
|
+
denominator: sharesOutstanding
|
|
4991
|
+
}).result;
|
|
4751
4992
|
const sender = this.sender.getUnconstrained();
|
|
4752
|
-
const senderUpdate =
|
|
4993
|
+
const senderUpdate = import_o1js24.AccountUpdate.createSigned(sender);
|
|
4753
4994
|
senderUpdate.balance.addInPlace(amountInMina);
|
|
4754
4995
|
this.balance.subInPlace(amountInMina);
|
|
4755
|
-
senderUpdate.body.useFullCommitment = (0,
|
|
4996
|
+
senderUpdate.body.useFullCommitment = (0, import_o1js24.Bool)(true);
|
|
4756
4997
|
this.sharesOutstanding.set(sharesOutstanding.sub(shares));
|
|
4757
4998
|
const data = NFTSharesData.unpack(this.data.getAndRequireEquals());
|
|
4758
4999
|
const token = new FungibleToken(data.owner);
|
|
@@ -4761,28 +5002,28 @@ function NFTSharesFactory(params) {
|
|
|
4761
5002
|
async closeSubscription() {
|
|
4762
5003
|
const data = this.ensureOwnerSignature();
|
|
4763
5004
|
const maxBuyPrice = data.maxBuyPrice;
|
|
4764
|
-
this.account.balance.requireBetween(maxBuyPrice,
|
|
4765
|
-
this.subscriptionOpen.set((0,
|
|
5005
|
+
this.account.balance.requireBetween(maxBuyPrice, import_o1js24.UInt64.MAXINT());
|
|
5006
|
+
this.subscriptionOpen.set((0, import_o1js24.Bool)(false));
|
|
4766
5007
|
}
|
|
4767
5008
|
async bid(price) {
|
|
4768
5009
|
const data = NFTSharesData.unpack(this.data.getAndRequireEquals());
|
|
4769
5010
|
const maxBuyPrice = data.maxBuyPrice;
|
|
4770
5011
|
price.assertLessThanOrEqual(maxBuyPrice, "Price is too high");
|
|
4771
|
-
this.account.balance.requireBetween(price,
|
|
4772
|
-
this.subscriptionOpen.set((0,
|
|
5012
|
+
this.account.balance.requireBetween(price, import_o1js24.UInt64.MAXINT());
|
|
5013
|
+
this.subscriptionOpen.set((0, import_o1js24.Bool)(false));
|
|
4773
5014
|
const sharesOutstanding = this.sharesOutstanding.getAndRequireEquals();
|
|
4774
5015
|
const auction = this.getAuction(data.auction);
|
|
4775
5016
|
const sender = this.sender.getUnconstrained();
|
|
4776
|
-
const senderUpdate =
|
|
4777
|
-
const tokenId =
|
|
4778
|
-
const tokenUpdate =
|
|
5017
|
+
const senderUpdate = import_o1js24.AccountUpdate.createSigned(sender);
|
|
5018
|
+
const tokenId = import_o1js24.TokenId.derive(data.owner);
|
|
5019
|
+
const tokenUpdate = import_o1js24.AccountUpdate.create(sender, tokenId);
|
|
4779
5020
|
const tokenBalance = tokenUpdate.account.balance.getAndRequireEquals();
|
|
4780
5021
|
const token = new FungibleToken(data.owner);
|
|
4781
5022
|
await token.approveAccountUpdate(tokenUpdate);
|
|
4782
5023
|
tokenBalance.mul(4).assertGreaterThanOrEqual(sharesOutstanding, "Not enough shares to bid, minimum is 25% of the shares outstanding");
|
|
4783
5024
|
senderUpdate.balance.addInPlace(price);
|
|
4784
5025
|
this.balance.subInPlace(price);
|
|
4785
|
-
senderUpdate.body.useFullCommitment = (0,
|
|
5026
|
+
senderUpdate.body.useFullCommitment = (0, import_o1js24.Bool)(true);
|
|
4786
5027
|
await auction.bid(price, this.address);
|
|
4787
5028
|
}
|
|
4788
5029
|
async canTransfer(params2) {
|
|
@@ -4792,100 +5033,100 @@ function NFTSharesFactory(params) {
|
|
|
4792
5033
|
const amount = params2.price.assertSome();
|
|
4793
5034
|
amount.assertGreaterThanOrEqual(data.minSellPrice, "Price is too low");
|
|
4794
5035
|
const sender = this.sender.getUnconstrained();
|
|
4795
|
-
const senderUpdate =
|
|
5036
|
+
const senderUpdate = import_o1js24.AccountUpdate.createSigned(sender);
|
|
4796
5037
|
senderUpdate.balance.subInPlace(amount);
|
|
4797
|
-
senderUpdate.body.useFullCommitment = (0,
|
|
5038
|
+
senderUpdate.body.useFullCommitment = (0, import_o1js24.Bool)(true);
|
|
4798
5039
|
this.balance.addInPlace(amount);
|
|
4799
|
-
return (0,
|
|
5040
|
+
return (0, import_o1js24.Bool)(true);
|
|
4800
5041
|
}
|
|
4801
5042
|
async canPause(collection, nft) {
|
|
4802
5043
|
this.ensureOwnerSignature();
|
|
4803
|
-
return (0,
|
|
5044
|
+
return (0, import_o1js24.Bool)(true);
|
|
4804
5045
|
}
|
|
4805
5046
|
async canResume(collection, nft) {
|
|
4806
5047
|
this.ensureOwnerSignature();
|
|
4807
|
-
return (0,
|
|
5048
|
+
return (0, import_o1js24.Bool)(true);
|
|
4808
5049
|
}
|
|
4809
5050
|
async canChangeVerificationKey(collection, nft, vk) {
|
|
4810
5051
|
this.ensureOwnerSignature();
|
|
4811
|
-
return (0,
|
|
5052
|
+
return (0, import_o1js24.Bool)(true);
|
|
4812
5053
|
}
|
|
4813
5054
|
async canApproveAddress(collection, nft, approved) {
|
|
4814
5055
|
this.ensureOwnerSignature();
|
|
4815
|
-
return (0,
|
|
5056
|
+
return (0, import_o1js24.Bool)(true);
|
|
4816
5057
|
}
|
|
4817
5058
|
}
|
|
4818
5059
|
(0, import_tslib11.__decorate)([
|
|
4819
|
-
(0,
|
|
5060
|
+
(0, import_o1js24.state)(NFTSharesDataPacked),
|
|
4820
5061
|
(0, import_tslib11.__metadata)("design:type", Object)
|
|
4821
5062
|
], NFTSharesOwner.prototype, "data", void 0);
|
|
4822
5063
|
(0, import_tslib11.__decorate)([
|
|
4823
|
-
(0,
|
|
5064
|
+
(0, import_o1js24.state)(import_o1js24.Bool),
|
|
4824
5065
|
(0, import_tslib11.__metadata)("design:type", Object)
|
|
4825
5066
|
], NFTSharesOwner.prototype, "subscriptionOpen", void 0);
|
|
4826
5067
|
(0, import_tslib11.__decorate)([
|
|
4827
|
-
(0,
|
|
5068
|
+
(0, import_o1js24.state)(import_o1js24.UInt64),
|
|
4828
5069
|
(0, import_tslib11.__metadata)("design:type", Object)
|
|
4829
5070
|
], NFTSharesOwner.prototype, "sharesOutstanding", void 0);
|
|
4830
5071
|
(0, import_tslib11.__decorate)([
|
|
4831
|
-
|
|
5072
|
+
import_o1js24.method.returns(import_o1js24.Bool),
|
|
4832
5073
|
(0, import_tslib11.__metadata)("design:type", Function),
|
|
4833
|
-
(0, import_tslib11.__metadata)("design:paramtypes", [
|
|
5074
|
+
(0, import_tslib11.__metadata)("design:paramtypes", [import_o1js24.AccountUpdate]),
|
|
4834
5075
|
(0, import_tslib11.__metadata)("design:returntype", Promise)
|
|
4835
5076
|
], NFTSharesOwner.prototype, "canMint", null);
|
|
4836
5077
|
(0, import_tslib11.__decorate)([
|
|
4837
|
-
|
|
5078
|
+
import_o1js24.method,
|
|
4838
5079
|
(0, import_tslib11.__metadata)("design:type", Function),
|
|
4839
|
-
(0, import_tslib11.__metadata)("design:paramtypes", [
|
|
5080
|
+
(0, import_tslib11.__metadata)("design:paramtypes", [import_o1js24.UInt64]),
|
|
4840
5081
|
(0, import_tslib11.__metadata)("design:returntype", Promise)
|
|
4841
5082
|
], NFTSharesOwner.prototype, "withdraw", null);
|
|
4842
5083
|
(0, import_tslib11.__decorate)([
|
|
4843
|
-
|
|
5084
|
+
import_o1js24.method,
|
|
4844
5085
|
(0, import_tslib11.__metadata)("design:type", Function),
|
|
4845
5086
|
(0, import_tslib11.__metadata)("design:paramtypes", []),
|
|
4846
5087
|
(0, import_tslib11.__metadata)("design:returntype", Promise)
|
|
4847
5088
|
], NFTSharesOwner.prototype, "closeSubscription", null);
|
|
4848
5089
|
(0, import_tslib11.__decorate)([
|
|
4849
|
-
|
|
5090
|
+
import_o1js24.method,
|
|
4850
5091
|
(0, import_tslib11.__metadata)("design:type", Function),
|
|
4851
|
-
(0, import_tslib11.__metadata)("design:paramtypes", [
|
|
5092
|
+
(0, import_tslib11.__metadata)("design:paramtypes", [import_o1js24.UInt64]),
|
|
4852
5093
|
(0, import_tslib11.__metadata)("design:returntype", Promise)
|
|
4853
5094
|
], NFTSharesOwner.prototype, "bid", null);
|
|
4854
5095
|
(0, import_tslib11.__decorate)([
|
|
4855
|
-
|
|
5096
|
+
import_o1js24.method.returns(import_o1js24.Bool),
|
|
4856
5097
|
(0, import_tslib11.__metadata)("design:type", Function),
|
|
4857
5098
|
(0, import_tslib11.__metadata)("design:paramtypes", [TransferExtendedParams]),
|
|
4858
5099
|
(0, import_tslib11.__metadata)("design:returntype", Promise)
|
|
4859
5100
|
], NFTSharesOwner.prototype, "canTransfer", null);
|
|
4860
5101
|
(0, import_tslib11.__decorate)([
|
|
4861
|
-
|
|
5102
|
+
import_o1js24.method.returns(import_o1js24.Bool),
|
|
4862
5103
|
(0, import_tslib11.__metadata)("design:type", Function),
|
|
4863
|
-
(0, import_tslib11.__metadata)("design:paramtypes", [
|
|
5104
|
+
(0, import_tslib11.__metadata)("design:paramtypes", [import_o1js24.PublicKey, import_o1js24.PublicKey]),
|
|
4864
5105
|
(0, import_tslib11.__metadata)("design:returntype", Promise)
|
|
4865
5106
|
], NFTSharesOwner.prototype, "canPause", null);
|
|
4866
5107
|
(0, import_tslib11.__decorate)([
|
|
4867
|
-
|
|
5108
|
+
import_o1js24.method.returns(import_o1js24.Bool),
|
|
4868
5109
|
(0, import_tslib11.__metadata)("design:type", Function),
|
|
4869
|
-
(0, import_tslib11.__metadata)("design:paramtypes", [
|
|
5110
|
+
(0, import_tslib11.__metadata)("design:paramtypes", [import_o1js24.PublicKey, import_o1js24.PublicKey]),
|
|
4870
5111
|
(0, import_tslib11.__metadata)("design:returntype", Promise)
|
|
4871
5112
|
], NFTSharesOwner.prototype, "canResume", null);
|
|
4872
5113
|
(0, import_tslib11.__decorate)([
|
|
4873
|
-
|
|
5114
|
+
import_o1js24.method.returns(import_o1js24.Bool),
|
|
4874
5115
|
(0, import_tslib11.__metadata)("design:type", Function),
|
|
4875
5116
|
(0, import_tslib11.__metadata)("design:paramtypes", [
|
|
4876
|
-
|
|
4877
|
-
|
|
4878
|
-
|
|
5117
|
+
import_o1js24.PublicKey,
|
|
5118
|
+
import_o1js24.PublicKey,
|
|
5119
|
+
import_o1js24.VerificationKey
|
|
4879
5120
|
]),
|
|
4880
5121
|
(0, import_tslib11.__metadata)("design:returntype", Promise)
|
|
4881
5122
|
], NFTSharesOwner.prototype, "canChangeVerificationKey", null);
|
|
4882
5123
|
(0, import_tslib11.__decorate)([
|
|
4883
|
-
|
|
5124
|
+
import_o1js24.method.returns(import_o1js24.Bool),
|
|
4884
5125
|
(0, import_tslib11.__metadata)("design:type", Function),
|
|
4885
5126
|
(0, import_tslib11.__metadata)("design:paramtypes", [
|
|
4886
|
-
|
|
4887
|
-
|
|
4888
|
-
|
|
5127
|
+
import_o1js24.PublicKey,
|
|
5128
|
+
import_o1js24.PublicKey,
|
|
5129
|
+
import_o1js24.PublicKey
|
|
4889
5130
|
]),
|
|
4890
5131
|
(0, import_tslib11.__metadata)("design:returntype", Promise)
|
|
4891
5132
|
], NFTSharesOwner.prototype, "canApproveAddress", null);
|
|
@@ -4988,6 +5229,7 @@ var { Collection: AdvancedCollection, Approval: AdvancedApproval, Owner: Advance
|
|
|
4988
5229
|
MintParams,
|
|
4989
5230
|
MintParamsOption,
|
|
4990
5231
|
MintRequest,
|
|
5232
|
+
MulDivResult,
|
|
4991
5233
|
NFT,
|
|
4992
5234
|
NFTAddress,
|
|
4993
5235
|
NFTAdmin,
|
|
@@ -5028,5 +5270,7 @@ var { Collection: AdvancedCollection, Approval: AdvancedApproval, Owner: Advance
|
|
|
5028
5270
|
WithdrawEvent,
|
|
5029
5271
|
fieldFromString,
|
|
5030
5272
|
fieldToString,
|
|
5031
|
-
|
|
5273
|
+
mulDiv,
|
|
5274
|
+
nftVerificationKeys,
|
|
5275
|
+
pinMetadata
|
|
5032
5276
|
});
|