@meshsdk/contract 1.7.10 → 1.7.11
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/index.cjs +199 -24
- package/dist/index.d.cts +193 -9
- package/dist/index.d.ts +193 -9
- package/dist/index.js +241 -60
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -987,7 +987,24 @@ var MeshContentOwnershipContract = class extends MeshTxInitiator {
|
|
|
987
987
|
scriptAddress
|
|
988
988
|
};
|
|
989
989
|
};
|
|
990
|
-
|
|
990
|
+
/**
|
|
991
|
+
* [Setup phase]
|
|
992
|
+
* This is the first transaction you need to setup the contract.
|
|
993
|
+
*
|
|
994
|
+
* This transaction mints the one-time minting policy (a NFT) for the contract.
|
|
995
|
+
* It will be attached with the datum which serves as the single source of truth for the contract oracle.
|
|
996
|
+
*
|
|
997
|
+
* Note: You must save the `paramUtxo` for future transactions.
|
|
998
|
+
*
|
|
999
|
+
* @returns {Promise<{ txHexMintOneTimeMintingPolicy: string, txHexSetupOracleUtxo: string, paramUtxo: UTxO["input"] }>}
|
|
1000
|
+
*
|
|
1001
|
+
* @example
|
|
1002
|
+
* ```typescript
|
|
1003
|
+
* const { tx, paramUtxo } = await contract.mintOneTimeMintingPolicy();
|
|
1004
|
+
* const signedTx = await wallet.signTx(tx);
|
|
1005
|
+
* const txHash = await wallet.submitTx(signedTx);
|
|
1006
|
+
* ```
|
|
1007
|
+
*/
|
|
991
1008
|
mintOneTimeMintingPolicy = async () => {
|
|
992
1009
|
const { utxos, collateral, walletAddress } = await this.getWalletInfoForTx();
|
|
993
1010
|
if (utxos?.length <= 0) {
|
|
@@ -1018,14 +1035,27 @@ var MeshContentOwnershipContract = class extends MeshTxInitiator {
|
|
|
1018
1035
|
this.stakeCredential,
|
|
1019
1036
|
this.networkId
|
|
1020
1037
|
);
|
|
1038
|
+
this.paramUtxo = paramUtxo.input;
|
|
1021
1039
|
return { tx: txHex, paramUtxo: paramUtxo.input };
|
|
1022
1040
|
};
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1041
|
+
/**
|
|
1042
|
+
* [Setup phase]
|
|
1043
|
+
* This is the second transaction you need to setup the contract.
|
|
1044
|
+
*
|
|
1045
|
+
* This transaction send the NFT to a oracle contract locking the datum,
|
|
1046
|
+
* which serves as the single source of truth for the contract oracle with data integrity.
|
|
1047
|
+
*
|
|
1048
|
+
* Note: You must provide the `paramUtxo` from the `mintOneTimeMintingPolicy` transaction.
|
|
1049
|
+
*
|
|
1050
|
+
* @returns {Promise<string>}
|
|
1051
|
+
*
|
|
1052
|
+
* @example
|
|
1053
|
+
* ```typescript
|
|
1054
|
+
* const txHex = await contract.setupOracleUtxo();
|
|
1055
|
+
* const signedTx = await wallet.signTx(txHex);
|
|
1056
|
+
* const txHash = await wallet.submitTx(signedTx);
|
|
1057
|
+
* ```
|
|
1058
|
+
*/
|
|
1029
1059
|
setupOracleUtxo = async () => {
|
|
1030
1060
|
const { utxos, walletAddress } = await this.getWalletInfoForTx();
|
|
1031
1061
|
const datumValue = this.getOracleDatum(0, 0);
|
|
@@ -1034,22 +1064,60 @@ var MeshContentOwnershipContract = class extends MeshTxInitiator {
|
|
|
1034
1064
|
]).txOutInlineDatumValue(datumValue).changeAddress(walletAddress).selectUtxosFrom(utxos).complete();
|
|
1035
1065
|
return txHex;
|
|
1036
1066
|
};
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1067
|
+
/**
|
|
1068
|
+
* [Setup phase]
|
|
1069
|
+
* This are the next transactions you need to setup the contract.
|
|
1070
|
+
* You need to run once for each script, and you would likely have to run one after the previous one is confirmed.
|
|
1071
|
+
*
|
|
1072
|
+
* This transaction sends the reference scripts to the blockchain for later transactions,
|
|
1073
|
+
* boosting efficiency and avoid exceeding 16kb of transaction size limits enforced by protocol parameter.
|
|
1074
|
+
*
|
|
1075
|
+
* Note: You must provide the `paramUtxo` from the `mintOneTimeMintingPolicy` transaction.
|
|
1076
|
+
* Note: You must save txHash (after signed and submitted) for `ContentRegistry`, `ContentRefToken`, `OwnershipRegistry`, `OwnershipRefToken` transactions for future transactions.
|
|
1077
|
+
*
|
|
1078
|
+
* @param scriptIndex - "OracleNFT" | "OracleValidator" | "ContentRegistry" | "ContentRefToken" | "OwnershipRegistry" | "OwnershipRefToken"
|
|
1079
|
+
* @returns {Promise<string>}
|
|
1080
|
+
*
|
|
1081
|
+
* @example
|
|
1082
|
+
* ```typescript
|
|
1083
|
+
* const txHexOracleNFT = await contract.sendRefScriptOnchain("OracleNFT");
|
|
1084
|
+
* const signedTxOracleNFT = await wallet.signTx(txHexOracleNFT);
|
|
1085
|
+
* const txHashOracleNFT = await wallet.submitTx(signedTxOracleNFT);
|
|
1086
|
+
*
|
|
1087
|
+
* const txHexOracleValidator = await contract.sendRefScriptOnchain("OracleValidator");
|
|
1088
|
+
* ... // repeat for each script
|
|
1089
|
+
*
|
|
1090
|
+
* const txHexOwnershipRefToken = await contract.sendRefScriptOnchain("OwnershipRefToken");
|
|
1091
|
+
* const signedTxOwnershipRefToken = await wallet.signTx(txHexOwnershipRefToken);
|
|
1092
|
+
* const txHashOwnershipRefToken = await wallet.submitTx(signedTxOwnershipRefToken);
|
|
1093
|
+
* ```
|
|
1094
|
+
*/
|
|
1095
|
+
sendRefScriptOnchain = async (scriptIndex) => {
|
|
1096
|
+
const { utxos, walletAddress } = await this.getWalletInfoForTx();
|
|
1097
|
+
const { scriptAddress } = this.getOwnerNativeScript();
|
|
1098
|
+
const txHex = await this.mesh.txOut(scriptAddress, []).txOutReferenceScript(getScriptCbor(this.paramUtxo, scriptIndex)).changeAddress(walletAddress).selectUtxosFrom(utxos, "experimental", "20000000").complete();
|
|
1099
|
+
return txHex;
|
|
1052
1100
|
};
|
|
1101
|
+
/**
|
|
1102
|
+
* [Setup phase]
|
|
1103
|
+
* This is the next transaction you need to setup the contract after completing all the `sendRefScriptOnchain` transactions.
|
|
1104
|
+
*
|
|
1105
|
+
* This transaction creates one content registry. Each registry should comes in pair with one ownership registry and
|
|
1106
|
+
* each pair of registry serves around 50 records of content ownership. The application can be scaled indefinitely
|
|
1107
|
+
* according to the number of parallelization needed and volumes of content expected to be managed.
|
|
1108
|
+
*
|
|
1109
|
+
* Note: You must provide the `paramUtxo` from the `mintOneTimeMintingPolicy` transaction.
|
|
1110
|
+
* Note: You must provide the txHash for `ContentRegistry`, `ContentRefToken`, `OwnershipRegistry`, `OwnershipRefToken`
|
|
1111
|
+
*
|
|
1112
|
+
* @returns {Promise<string>}
|
|
1113
|
+
*
|
|
1114
|
+
* @example
|
|
1115
|
+
* ```typescript
|
|
1116
|
+
* const txHex = await contract.createContentRegistry();
|
|
1117
|
+
* const signedTx = await wallet.signTx(txHex);
|
|
1118
|
+
* const txHash = await wallet.submitTx(signedTx);
|
|
1119
|
+
* ```
|
|
1120
|
+
*/
|
|
1053
1121
|
createContentRegistry = async () => {
|
|
1054
1122
|
const { utxos, collateral, walletAddress } = await this.getWalletInfoForTx();
|
|
1055
1123
|
const scriptUtxo = await this.fetcher.fetchAddressUTxOs(
|
|
@@ -1090,6 +1158,26 @@ var MeshContentOwnershipContract = class extends MeshTxInitiator {
|
|
|
1090
1158
|
).changeAddress(walletAddress).selectUtxosFrom(utxos, "largestFirstMultiAsset").complete();
|
|
1091
1159
|
return txHex;
|
|
1092
1160
|
};
|
|
1161
|
+
/**
|
|
1162
|
+
* [Setup phase]
|
|
1163
|
+
* This is the last transaction you need to setup the contract after completing all the `sendRefScriptOnchain` transactions.
|
|
1164
|
+
*
|
|
1165
|
+
* This transaction creates one content registry. Each registry should comes in pair with one content registry and
|
|
1166
|
+
* each pair of registry serves around 50 records of content ownership. The application can be scaled indefinitely
|
|
1167
|
+
* according to the number of parallelization needed and volumes of content expected to be managed.
|
|
1168
|
+
*
|
|
1169
|
+
* Note: You must provide the `paramUtxo` from the `mintOneTimeMintingPolicy` transaction.
|
|
1170
|
+
* Note: You must provide the txHash for `ContentRegistry`, `ContentRefToken`, `OwnershipRegistry`, `OwnershipRefToken`
|
|
1171
|
+
*
|
|
1172
|
+
* @returns {Promise<string>}
|
|
1173
|
+
*
|
|
1174
|
+
* @example
|
|
1175
|
+
* ```typescript
|
|
1176
|
+
* const txHex = await contract.createOwnershipRegistry();
|
|
1177
|
+
* const signedTx = await wallet.signTx(txHex);
|
|
1178
|
+
* const txHash = await wallet.submitTx(signedTx);
|
|
1179
|
+
* ```
|
|
1180
|
+
*/
|
|
1093
1181
|
createOwnershipRegistry = async () => {
|
|
1094
1182
|
const { utxos, collateral, walletAddress } = await this.getWalletInfoForTx();
|
|
1095
1183
|
const scriptUtxo = await this.fetcher.fetchAddressUTxOs(
|
|
@@ -1126,10 +1214,79 @@ var MeshContentOwnershipContract = class extends MeshTxInitiator {
|
|
|
1126
1214
|
collateral.input.outputIndex,
|
|
1127
1215
|
collateral.output.amount,
|
|
1128
1216
|
collateral.output.address
|
|
1129
|
-
).changeAddress(walletAddress).selectUtxosFrom(utxos).complete();
|
|
1217
|
+
).changeAddress(walletAddress).selectUtxosFrom(utxos, "largestFirstMultiAsset").complete();
|
|
1218
|
+
return txHex;
|
|
1219
|
+
};
|
|
1220
|
+
/**
|
|
1221
|
+
* Get the current oracle data.
|
|
1222
|
+
*
|
|
1223
|
+
* @returns {Promise<{
|
|
1224
|
+
* contentNumber: number,
|
|
1225
|
+
* ownershipNumber: number,
|
|
1226
|
+
* }>}
|
|
1227
|
+
*
|
|
1228
|
+
* @example
|
|
1229
|
+
* ```typescript
|
|
1230
|
+
* const oracleData = await contract.getOracleData();
|
|
1231
|
+
* ```
|
|
1232
|
+
*/
|
|
1233
|
+
getOracleData = async () => {
|
|
1234
|
+
const scriptUtxo = await this.fetcher.fetchAddressUTxOs(
|
|
1235
|
+
this.scriptInfo.oracleValidator.address,
|
|
1236
|
+
this.scriptInfo.oracleNFT.hash
|
|
1237
|
+
);
|
|
1238
|
+
const currentOracleDatum = await this.getCurrentOracleDatum(scriptUtxo);
|
|
1239
|
+
const contentNumber = currentOracleDatum.fields[4].int;
|
|
1240
|
+
const ownershipNumber = currentOracleDatum.fields[7].int;
|
|
1241
|
+
return {
|
|
1242
|
+
contentNumber,
|
|
1243
|
+
ownershipNumber
|
|
1244
|
+
};
|
|
1245
|
+
};
|
|
1246
|
+
/**
|
|
1247
|
+
* [User]
|
|
1248
|
+
*
|
|
1249
|
+
* This transaction mints a user token which can be used to represent the ownership of the content. This token is used in `createContent()` transaction.
|
|
1250
|
+
*
|
|
1251
|
+
* @param tokenName - The name of the token that you can specify.
|
|
1252
|
+
* @param tokenMetadata - The metadata of the token that you can specify.
|
|
1253
|
+
* @returns {Promise<string>}
|
|
1254
|
+
*
|
|
1255
|
+
* @example
|
|
1256
|
+
* ```typescript
|
|
1257
|
+
* const tx = await contract.mintUserToken("MeshContentOwnership", {
|
|
1258
|
+
* name: "Mesh Content Ownership",
|
|
1259
|
+
* description: "Demo at https://meshjs.dev/smart-contracts/content-ownership",
|
|
1260
|
+
* });
|
|
1261
|
+
* const signedTx = await wallet.signTx(tx, true);
|
|
1262
|
+
* const txHash = await wallet.submitTx(signedTx);
|
|
1263
|
+
*/
|
|
1264
|
+
mintUserToken = async (tokenName2, tokenMetadata = {}) => {
|
|
1265
|
+
const { utxos, walletAddress } = await this.getWalletInfoForTx();
|
|
1266
|
+
const { pubKeyHash: keyHash } = (0, import_core3.deserializeAddress)(walletAddress);
|
|
1267
|
+
const nativeScript = {
|
|
1268
|
+
type: "all",
|
|
1269
|
+
scripts: [
|
|
1270
|
+
{
|
|
1271
|
+
type: "sig",
|
|
1272
|
+
keyHash
|
|
1273
|
+
}
|
|
1274
|
+
]
|
|
1275
|
+
};
|
|
1276
|
+
const forgingScript = import_core3.ForgeScript.fromNativeScript(nativeScript);
|
|
1277
|
+
const policyId = (0, import_core3.resolveScriptHash)(forgingScript);
|
|
1278
|
+
const tokenNameHex = (0, import_core3.stringToHex)(tokenName2);
|
|
1279
|
+
const metadata = { [policyId]: { [tokenName2]: { ...tokenMetadata } } };
|
|
1280
|
+
const txHex = await this.mesh.mint("1", policyId, tokenNameHex).mintingScript(forgingScript).metadataValue("721", metadata).changeAddress(walletAddress).selectUtxosFrom(utxos).complete();
|
|
1130
1281
|
return txHex;
|
|
1131
1282
|
};
|
|
1132
|
-
|
|
1283
|
+
/**
|
|
1284
|
+
*
|
|
1285
|
+
* @param ownerAssetHex
|
|
1286
|
+
* @param contentHashHex
|
|
1287
|
+
* @param registryNumber
|
|
1288
|
+
* @returns
|
|
1289
|
+
*/
|
|
1133
1290
|
createContent = async (ownerAssetHex, contentHashHex, registryNumber = 0) => {
|
|
1134
1291
|
const { utxos, collateral, walletAddress } = await this.getWalletInfoForTx();
|
|
1135
1292
|
const registryName = (0, import_core3.stringToHex)(`Registry (${registryNumber})`);
|
|
@@ -1199,6 +1356,24 @@ var MeshContentOwnershipContract = class extends MeshTxInitiator {
|
|
|
1199
1356
|
).selectUtxosFrom(utxos).complete();
|
|
1200
1357
|
return txHex;
|
|
1201
1358
|
};
|
|
1359
|
+
/**
|
|
1360
|
+
* Get the content at the registry given the registry number and content number.
|
|
1361
|
+
* @param registryNumber
|
|
1362
|
+
* @param contentNumber
|
|
1363
|
+
* @returns
|
|
1364
|
+
*/
|
|
1365
|
+
getContent = async (registryNumber, contentNumber) => {
|
|
1366
|
+
const [content] = await this.getScriptUtxos(registryNumber, ["content"]);
|
|
1367
|
+
if (content === void 0) throw new Error("Content registry not found");
|
|
1368
|
+
const contentDatam = (0, import_core_csl2.parseDatumCbor)(
|
|
1369
|
+
content.output.plutusData
|
|
1370
|
+
);
|
|
1371
|
+
const contentAtRegistry = contentDatam.fields[1].list;
|
|
1372
|
+
if (contentAtRegistry.length <= contentNumber)
|
|
1373
|
+
throw new Error("Content not found");
|
|
1374
|
+
const decoded = (0, import_core3.toUTF8)(contentAtRegistry[contentNumber]?.bytes);
|
|
1375
|
+
return decoded;
|
|
1376
|
+
};
|
|
1202
1377
|
updateContent = async ({
|
|
1203
1378
|
ownerTokenUtxo,
|
|
1204
1379
|
registryNumber,
|
package/dist/index.d.cts
CHANGED
|
@@ -63,6 +63,44 @@ type TransferContent = {
|
|
|
63
63
|
contentNumber: number;
|
|
64
64
|
};
|
|
65
65
|
|
|
66
|
+
/**
|
|
67
|
+
* Mesh Content Ownership Contract
|
|
68
|
+
*
|
|
69
|
+
* This contract is used to manage the ownership of content.
|
|
70
|
+
* It facilitates on-chain record of content (i.e. file on IPFS) ownership and transfer.
|
|
71
|
+
* While one cannot prefer others from obtaining a copy of the content, the app owner of the
|
|
72
|
+
* contract can serve the single source of truth of who owns the content. With the blockchain
|
|
73
|
+
* trace and record in place, it provides a trustless way to verify the ownership of the content
|
|
74
|
+
* and facilitates further application logics such as royalties, licensing, etc.
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```typescript
|
|
78
|
+
* const meshTxBuilder = new MeshTxBuilder({
|
|
79
|
+
* fetcher: blockchainProvider, // one of the Providers
|
|
80
|
+
* submitter: blockchainProvider,
|
|
81
|
+
* verbose: true,
|
|
82
|
+
* });
|
|
83
|
+
*
|
|
84
|
+
* const contract = new MeshContentOwnershipContract(
|
|
85
|
+
* {
|
|
86
|
+
* mesh: meshTxBuilder,
|
|
87
|
+
* fetcher: blockchainProvider,
|
|
88
|
+
* wallet: wallet,
|
|
89
|
+
* networkId: 0,
|
|
90
|
+
* },
|
|
91
|
+
* {
|
|
92
|
+
* operationAddress: operationAddress, // the address of the app owner, where most of the actions should be signed by the spending key of this address
|
|
93
|
+
* paramUtxo: { outputIndex: 0, txHash: "0000000000000000000000000000000000000000000000000000000000000000" }, // you can get this from the output of `mintOneTimeMintingPolicy()` transaction
|
|
94
|
+
* refScriptUtxos?: { // you can get these from the output of `sendRefScriptOnchain()` transactions
|
|
95
|
+
* contentRegistry: { outputIndex: 0, txHash: "0000000000000000000000000000000000000000000000000000000000000000" },
|
|
96
|
+
* contentRefToken: { outputIndex: 0, txHash: "0000000000000000000000000000000000000000000000000000000000000000" },
|
|
97
|
+
* ownershipRegistry: { outputIndex: 0, txHash: "0000000000000000000000000000000000000000000000000000000000000000" },
|
|
98
|
+
* ownershipRefToken: { outputIndex: 0, txHash: "0000000000000000000000000000000000000000000000000000000000000000" },
|
|
99
|
+
* },
|
|
100
|
+
* },
|
|
101
|
+
* );
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
66
104
|
declare class MeshContentOwnershipContract extends MeshTxInitiator {
|
|
67
105
|
paramUtxo: {
|
|
68
106
|
txHash: string;
|
|
@@ -134,6 +172,24 @@ declare class MeshContentOwnershipContract extends MeshTxInitiator {
|
|
|
134
172
|
};
|
|
135
173
|
scriptAddress: string;
|
|
136
174
|
};
|
|
175
|
+
/**
|
|
176
|
+
* [Setup phase]
|
|
177
|
+
* This is the first transaction you need to setup the contract.
|
|
178
|
+
*
|
|
179
|
+
* This transaction mints the one-time minting policy (a NFT) for the contract.
|
|
180
|
+
* It will be attached with the datum which serves as the single source of truth for the contract oracle.
|
|
181
|
+
*
|
|
182
|
+
* Note: You must save the `paramUtxo` for future transactions.
|
|
183
|
+
*
|
|
184
|
+
* @returns {Promise<{ txHexMintOneTimeMintingPolicy: string, txHexSetupOracleUtxo: string, paramUtxo: UTxO["input"] }>}
|
|
185
|
+
*
|
|
186
|
+
* @example
|
|
187
|
+
* ```typescript
|
|
188
|
+
* const { tx, paramUtxo } = await contract.mintOneTimeMintingPolicy();
|
|
189
|
+
* const signedTx = await wallet.signTx(tx);
|
|
190
|
+
* const txHash = await wallet.submitTx(signedTx);
|
|
191
|
+
* ```
|
|
192
|
+
*/
|
|
137
193
|
mintOneTimeMintingPolicy: () => Promise<{
|
|
138
194
|
tx: string;
|
|
139
195
|
paramUtxo: {
|
|
@@ -141,19 +197,147 @@ declare class MeshContentOwnershipContract extends MeshTxInitiator {
|
|
|
141
197
|
txHash: string;
|
|
142
198
|
};
|
|
143
199
|
}>;
|
|
144
|
-
|
|
200
|
+
/**
|
|
201
|
+
* [Setup phase]
|
|
202
|
+
* This is the second transaction you need to setup the contract.
|
|
203
|
+
*
|
|
204
|
+
* This transaction send the NFT to a oracle contract locking the datum,
|
|
205
|
+
* which serves as the single source of truth for the contract oracle with data integrity.
|
|
206
|
+
*
|
|
207
|
+
* Note: You must provide the `paramUtxo` from the `mintOneTimeMintingPolicy` transaction.
|
|
208
|
+
*
|
|
209
|
+
* @returns {Promise<string>}
|
|
210
|
+
*
|
|
211
|
+
* @example
|
|
212
|
+
* ```typescript
|
|
213
|
+
* const txHex = await contract.setupOracleUtxo();
|
|
214
|
+
* const signedTx = await wallet.signTx(txHex);
|
|
215
|
+
* const txHash = await wallet.submitTx(signedTx);
|
|
216
|
+
* ```
|
|
217
|
+
*/
|
|
145
218
|
setupOracleUtxo: () => Promise<string>;
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
219
|
+
/**
|
|
220
|
+
* [Setup phase]
|
|
221
|
+
* This are the next transactions you need to setup the contract.
|
|
222
|
+
* You need to run once for each script, and you would likely have to run one after the previous one is confirmed.
|
|
223
|
+
*
|
|
224
|
+
* This transaction sends the reference scripts to the blockchain for later transactions,
|
|
225
|
+
* boosting efficiency and avoid exceeding 16kb of transaction size limits enforced by protocol parameter.
|
|
226
|
+
*
|
|
227
|
+
* Note: You must provide the `paramUtxo` from the `mintOneTimeMintingPolicy` transaction.
|
|
228
|
+
* Note: You must save txHash (after signed and submitted) for `ContentRegistry`, `ContentRefToken`, `OwnershipRegistry`, `OwnershipRefToken` transactions for future transactions.
|
|
229
|
+
*
|
|
230
|
+
* @param scriptIndex - "OracleNFT" | "OracleValidator" | "ContentRegistry" | "ContentRefToken" | "OwnershipRegistry" | "OwnershipRefToken"
|
|
231
|
+
* @returns {Promise<string>}
|
|
232
|
+
*
|
|
233
|
+
* @example
|
|
234
|
+
* ```typescript
|
|
235
|
+
* const txHexOracleNFT = await contract.sendRefScriptOnchain("OracleNFT");
|
|
236
|
+
* const signedTxOracleNFT = await wallet.signTx(txHexOracleNFT);
|
|
237
|
+
* const txHashOracleNFT = await wallet.submitTx(signedTxOracleNFT);
|
|
238
|
+
*
|
|
239
|
+
* const txHexOracleValidator = await contract.sendRefScriptOnchain("OracleValidator");
|
|
240
|
+
* ... // repeat for each script
|
|
241
|
+
*
|
|
242
|
+
* const txHexOwnershipRefToken = await contract.sendRefScriptOnchain("OwnershipRefToken");
|
|
243
|
+
* const signedTxOwnershipRefToken = await wallet.signTx(txHexOwnershipRefToken);
|
|
244
|
+
* const txHashOwnershipRefToken = await wallet.submitTx(signedTxOwnershipRefToken);
|
|
245
|
+
* ```
|
|
246
|
+
*/
|
|
247
|
+
sendRefScriptOnchain: (scriptIndex: ScriptIndex) => Promise<string>;
|
|
248
|
+
/**
|
|
249
|
+
* [Setup phase]
|
|
250
|
+
* This is the next transaction you need to setup the contract after completing all the `sendRefScriptOnchain` transactions.
|
|
251
|
+
*
|
|
252
|
+
* This transaction creates one content registry. Each registry should comes in pair with one ownership registry and
|
|
253
|
+
* each pair of registry serves around 50 records of content ownership. The application can be scaled indefinitely
|
|
254
|
+
* according to the number of parallelization needed and volumes of content expected to be managed.
|
|
255
|
+
*
|
|
256
|
+
* Note: You must provide the `paramUtxo` from the `mintOneTimeMintingPolicy` transaction.
|
|
257
|
+
* Note: You must provide the txHash for `ContentRegistry`, `ContentRefToken`, `OwnershipRegistry`, `OwnershipRefToken`
|
|
258
|
+
*
|
|
259
|
+
* @returns {Promise<string>}
|
|
260
|
+
*
|
|
261
|
+
* @example
|
|
262
|
+
* ```typescript
|
|
263
|
+
* const txHex = await contract.createContentRegistry();
|
|
264
|
+
* const signedTx = await wallet.signTx(txHex);
|
|
265
|
+
* const txHash = await wallet.submitTx(signedTx);
|
|
266
|
+
* ```
|
|
267
|
+
*/
|
|
154
268
|
createContentRegistry: () => Promise<string>;
|
|
269
|
+
/**
|
|
270
|
+
* [Setup phase]
|
|
271
|
+
* This is the last transaction you need to setup the contract after completing all the `sendRefScriptOnchain` transactions.
|
|
272
|
+
*
|
|
273
|
+
* This transaction creates one content registry. Each registry should comes in pair with one content registry and
|
|
274
|
+
* each pair of registry serves around 50 records of content ownership. The application can be scaled indefinitely
|
|
275
|
+
* according to the number of parallelization needed and volumes of content expected to be managed.
|
|
276
|
+
*
|
|
277
|
+
* Note: You must provide the `paramUtxo` from the `mintOneTimeMintingPolicy` transaction.
|
|
278
|
+
* Note: You must provide the txHash for `ContentRegistry`, `ContentRefToken`, `OwnershipRegistry`, `OwnershipRefToken`
|
|
279
|
+
*
|
|
280
|
+
* @returns {Promise<string>}
|
|
281
|
+
*
|
|
282
|
+
* @example
|
|
283
|
+
* ```typescript
|
|
284
|
+
* const txHex = await contract.createOwnershipRegistry();
|
|
285
|
+
* const signedTx = await wallet.signTx(txHex);
|
|
286
|
+
* const txHash = await wallet.submitTx(signedTx);
|
|
287
|
+
* ```
|
|
288
|
+
*/
|
|
155
289
|
createOwnershipRegistry: () => Promise<string>;
|
|
290
|
+
/**
|
|
291
|
+
* Get the current oracle data.
|
|
292
|
+
*
|
|
293
|
+
* @returns {Promise<{
|
|
294
|
+
* contentNumber: number,
|
|
295
|
+
* ownershipNumber: number,
|
|
296
|
+
* }>}
|
|
297
|
+
*
|
|
298
|
+
* @example
|
|
299
|
+
* ```typescript
|
|
300
|
+
* const oracleData = await contract.getOracleData();
|
|
301
|
+
* ```
|
|
302
|
+
*/
|
|
303
|
+
getOracleData: () => Promise<{
|
|
304
|
+
contentNumber: number;
|
|
305
|
+
ownershipNumber: number;
|
|
306
|
+
}>;
|
|
307
|
+
/**
|
|
308
|
+
* [User]
|
|
309
|
+
*
|
|
310
|
+
* This transaction mints a user token which can be used to represent the ownership of the content. This token is used in `createContent()` transaction.
|
|
311
|
+
*
|
|
312
|
+
* @param tokenName - The name of the token that you can specify.
|
|
313
|
+
* @param tokenMetadata - The metadata of the token that you can specify.
|
|
314
|
+
* @returns {Promise<string>}
|
|
315
|
+
*
|
|
316
|
+
* @example
|
|
317
|
+
* ```typescript
|
|
318
|
+
* const tx = await contract.mintUserToken("MeshContentOwnership", {
|
|
319
|
+
* name: "Mesh Content Ownership",
|
|
320
|
+
* description: "Demo at https://meshjs.dev/smart-contracts/content-ownership",
|
|
321
|
+
* });
|
|
322
|
+
* const signedTx = await wallet.signTx(tx, true);
|
|
323
|
+
* const txHash = await wallet.submitTx(signedTx);
|
|
324
|
+
*/
|
|
325
|
+
mintUserToken: (tokenName: string, tokenMetadata?: {}) => Promise<string>;
|
|
326
|
+
/**
|
|
327
|
+
*
|
|
328
|
+
* @param ownerAssetHex
|
|
329
|
+
* @param contentHashHex
|
|
330
|
+
* @param registryNumber
|
|
331
|
+
* @returns
|
|
332
|
+
*/
|
|
156
333
|
createContent: (ownerAssetHex: string, contentHashHex: string, registryNumber?: number) => Promise<string>;
|
|
334
|
+
/**
|
|
335
|
+
* Get the content at the registry given the registry number and content number.
|
|
336
|
+
* @param registryNumber
|
|
337
|
+
* @param contentNumber
|
|
338
|
+
* @returns
|
|
339
|
+
*/
|
|
340
|
+
getContent: (registryNumber: number, contentNumber: number) => Promise<string>;
|
|
157
341
|
updateContent: ({ ownerTokenUtxo, registryNumber, newContentHashHex, contentNumber, }: UpdateContent) => Promise<string>;
|
|
158
342
|
transferContent: ({ ownerTokenUtxo, registryNumber, newOwnerAssetHex, contentNumber, }: TransferContent) => Promise<string>;
|
|
159
343
|
stopContentRegistry: (registryNumber: number) => Promise<string>;
|
package/dist/index.d.ts
CHANGED
|
@@ -63,6 +63,44 @@ type TransferContent = {
|
|
|
63
63
|
contentNumber: number;
|
|
64
64
|
};
|
|
65
65
|
|
|
66
|
+
/**
|
|
67
|
+
* Mesh Content Ownership Contract
|
|
68
|
+
*
|
|
69
|
+
* This contract is used to manage the ownership of content.
|
|
70
|
+
* It facilitates on-chain record of content (i.e. file on IPFS) ownership and transfer.
|
|
71
|
+
* While one cannot prefer others from obtaining a copy of the content, the app owner of the
|
|
72
|
+
* contract can serve the single source of truth of who owns the content. With the blockchain
|
|
73
|
+
* trace and record in place, it provides a trustless way to verify the ownership of the content
|
|
74
|
+
* and facilitates further application logics such as royalties, licensing, etc.
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```typescript
|
|
78
|
+
* const meshTxBuilder = new MeshTxBuilder({
|
|
79
|
+
* fetcher: blockchainProvider, // one of the Providers
|
|
80
|
+
* submitter: blockchainProvider,
|
|
81
|
+
* verbose: true,
|
|
82
|
+
* });
|
|
83
|
+
*
|
|
84
|
+
* const contract = new MeshContentOwnershipContract(
|
|
85
|
+
* {
|
|
86
|
+
* mesh: meshTxBuilder,
|
|
87
|
+
* fetcher: blockchainProvider,
|
|
88
|
+
* wallet: wallet,
|
|
89
|
+
* networkId: 0,
|
|
90
|
+
* },
|
|
91
|
+
* {
|
|
92
|
+
* operationAddress: operationAddress, // the address of the app owner, where most of the actions should be signed by the spending key of this address
|
|
93
|
+
* paramUtxo: { outputIndex: 0, txHash: "0000000000000000000000000000000000000000000000000000000000000000" }, // you can get this from the output of `mintOneTimeMintingPolicy()` transaction
|
|
94
|
+
* refScriptUtxos?: { // you can get these from the output of `sendRefScriptOnchain()` transactions
|
|
95
|
+
* contentRegistry: { outputIndex: 0, txHash: "0000000000000000000000000000000000000000000000000000000000000000" },
|
|
96
|
+
* contentRefToken: { outputIndex: 0, txHash: "0000000000000000000000000000000000000000000000000000000000000000" },
|
|
97
|
+
* ownershipRegistry: { outputIndex: 0, txHash: "0000000000000000000000000000000000000000000000000000000000000000" },
|
|
98
|
+
* ownershipRefToken: { outputIndex: 0, txHash: "0000000000000000000000000000000000000000000000000000000000000000" },
|
|
99
|
+
* },
|
|
100
|
+
* },
|
|
101
|
+
* );
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
66
104
|
declare class MeshContentOwnershipContract extends MeshTxInitiator {
|
|
67
105
|
paramUtxo: {
|
|
68
106
|
txHash: string;
|
|
@@ -134,6 +172,24 @@ declare class MeshContentOwnershipContract extends MeshTxInitiator {
|
|
|
134
172
|
};
|
|
135
173
|
scriptAddress: string;
|
|
136
174
|
};
|
|
175
|
+
/**
|
|
176
|
+
* [Setup phase]
|
|
177
|
+
* This is the first transaction you need to setup the contract.
|
|
178
|
+
*
|
|
179
|
+
* This transaction mints the one-time minting policy (a NFT) for the contract.
|
|
180
|
+
* It will be attached with the datum which serves as the single source of truth for the contract oracle.
|
|
181
|
+
*
|
|
182
|
+
* Note: You must save the `paramUtxo` for future transactions.
|
|
183
|
+
*
|
|
184
|
+
* @returns {Promise<{ txHexMintOneTimeMintingPolicy: string, txHexSetupOracleUtxo: string, paramUtxo: UTxO["input"] }>}
|
|
185
|
+
*
|
|
186
|
+
* @example
|
|
187
|
+
* ```typescript
|
|
188
|
+
* const { tx, paramUtxo } = await contract.mintOneTimeMintingPolicy();
|
|
189
|
+
* const signedTx = await wallet.signTx(tx);
|
|
190
|
+
* const txHash = await wallet.submitTx(signedTx);
|
|
191
|
+
* ```
|
|
192
|
+
*/
|
|
137
193
|
mintOneTimeMintingPolicy: () => Promise<{
|
|
138
194
|
tx: string;
|
|
139
195
|
paramUtxo: {
|
|
@@ -141,19 +197,147 @@ declare class MeshContentOwnershipContract extends MeshTxInitiator {
|
|
|
141
197
|
txHash: string;
|
|
142
198
|
};
|
|
143
199
|
}>;
|
|
144
|
-
|
|
200
|
+
/**
|
|
201
|
+
* [Setup phase]
|
|
202
|
+
* This is the second transaction you need to setup the contract.
|
|
203
|
+
*
|
|
204
|
+
* This transaction send the NFT to a oracle contract locking the datum,
|
|
205
|
+
* which serves as the single source of truth for the contract oracle with data integrity.
|
|
206
|
+
*
|
|
207
|
+
* Note: You must provide the `paramUtxo` from the `mintOneTimeMintingPolicy` transaction.
|
|
208
|
+
*
|
|
209
|
+
* @returns {Promise<string>}
|
|
210
|
+
*
|
|
211
|
+
* @example
|
|
212
|
+
* ```typescript
|
|
213
|
+
* const txHex = await contract.setupOracleUtxo();
|
|
214
|
+
* const signedTx = await wallet.signTx(txHex);
|
|
215
|
+
* const txHash = await wallet.submitTx(signedTx);
|
|
216
|
+
* ```
|
|
217
|
+
*/
|
|
145
218
|
setupOracleUtxo: () => Promise<string>;
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
219
|
+
/**
|
|
220
|
+
* [Setup phase]
|
|
221
|
+
* This are the next transactions you need to setup the contract.
|
|
222
|
+
* You need to run once for each script, and you would likely have to run one after the previous one is confirmed.
|
|
223
|
+
*
|
|
224
|
+
* This transaction sends the reference scripts to the blockchain for later transactions,
|
|
225
|
+
* boosting efficiency and avoid exceeding 16kb of transaction size limits enforced by protocol parameter.
|
|
226
|
+
*
|
|
227
|
+
* Note: You must provide the `paramUtxo` from the `mintOneTimeMintingPolicy` transaction.
|
|
228
|
+
* Note: You must save txHash (after signed and submitted) for `ContentRegistry`, `ContentRefToken`, `OwnershipRegistry`, `OwnershipRefToken` transactions for future transactions.
|
|
229
|
+
*
|
|
230
|
+
* @param scriptIndex - "OracleNFT" | "OracleValidator" | "ContentRegistry" | "ContentRefToken" | "OwnershipRegistry" | "OwnershipRefToken"
|
|
231
|
+
* @returns {Promise<string>}
|
|
232
|
+
*
|
|
233
|
+
* @example
|
|
234
|
+
* ```typescript
|
|
235
|
+
* const txHexOracleNFT = await contract.sendRefScriptOnchain("OracleNFT");
|
|
236
|
+
* const signedTxOracleNFT = await wallet.signTx(txHexOracleNFT);
|
|
237
|
+
* const txHashOracleNFT = await wallet.submitTx(signedTxOracleNFT);
|
|
238
|
+
*
|
|
239
|
+
* const txHexOracleValidator = await contract.sendRefScriptOnchain("OracleValidator");
|
|
240
|
+
* ... // repeat for each script
|
|
241
|
+
*
|
|
242
|
+
* const txHexOwnershipRefToken = await contract.sendRefScriptOnchain("OwnershipRefToken");
|
|
243
|
+
* const signedTxOwnershipRefToken = await wallet.signTx(txHexOwnershipRefToken);
|
|
244
|
+
* const txHashOwnershipRefToken = await wallet.submitTx(signedTxOwnershipRefToken);
|
|
245
|
+
* ```
|
|
246
|
+
*/
|
|
247
|
+
sendRefScriptOnchain: (scriptIndex: ScriptIndex) => Promise<string>;
|
|
248
|
+
/**
|
|
249
|
+
* [Setup phase]
|
|
250
|
+
* This is the next transaction you need to setup the contract after completing all the `sendRefScriptOnchain` transactions.
|
|
251
|
+
*
|
|
252
|
+
* This transaction creates one content registry. Each registry should comes in pair with one ownership registry and
|
|
253
|
+
* each pair of registry serves around 50 records of content ownership. The application can be scaled indefinitely
|
|
254
|
+
* according to the number of parallelization needed and volumes of content expected to be managed.
|
|
255
|
+
*
|
|
256
|
+
* Note: You must provide the `paramUtxo` from the `mintOneTimeMintingPolicy` transaction.
|
|
257
|
+
* Note: You must provide the txHash for `ContentRegistry`, `ContentRefToken`, `OwnershipRegistry`, `OwnershipRefToken`
|
|
258
|
+
*
|
|
259
|
+
* @returns {Promise<string>}
|
|
260
|
+
*
|
|
261
|
+
* @example
|
|
262
|
+
* ```typescript
|
|
263
|
+
* const txHex = await contract.createContentRegistry();
|
|
264
|
+
* const signedTx = await wallet.signTx(txHex);
|
|
265
|
+
* const txHash = await wallet.submitTx(signedTx);
|
|
266
|
+
* ```
|
|
267
|
+
*/
|
|
154
268
|
createContentRegistry: () => Promise<string>;
|
|
269
|
+
/**
|
|
270
|
+
* [Setup phase]
|
|
271
|
+
* This is the last transaction you need to setup the contract after completing all the `sendRefScriptOnchain` transactions.
|
|
272
|
+
*
|
|
273
|
+
* This transaction creates one content registry. Each registry should comes in pair with one content registry and
|
|
274
|
+
* each pair of registry serves around 50 records of content ownership. The application can be scaled indefinitely
|
|
275
|
+
* according to the number of parallelization needed and volumes of content expected to be managed.
|
|
276
|
+
*
|
|
277
|
+
* Note: You must provide the `paramUtxo` from the `mintOneTimeMintingPolicy` transaction.
|
|
278
|
+
* Note: You must provide the txHash for `ContentRegistry`, `ContentRefToken`, `OwnershipRegistry`, `OwnershipRefToken`
|
|
279
|
+
*
|
|
280
|
+
* @returns {Promise<string>}
|
|
281
|
+
*
|
|
282
|
+
* @example
|
|
283
|
+
* ```typescript
|
|
284
|
+
* const txHex = await contract.createOwnershipRegistry();
|
|
285
|
+
* const signedTx = await wallet.signTx(txHex);
|
|
286
|
+
* const txHash = await wallet.submitTx(signedTx);
|
|
287
|
+
* ```
|
|
288
|
+
*/
|
|
155
289
|
createOwnershipRegistry: () => Promise<string>;
|
|
290
|
+
/**
|
|
291
|
+
* Get the current oracle data.
|
|
292
|
+
*
|
|
293
|
+
* @returns {Promise<{
|
|
294
|
+
* contentNumber: number,
|
|
295
|
+
* ownershipNumber: number,
|
|
296
|
+
* }>}
|
|
297
|
+
*
|
|
298
|
+
* @example
|
|
299
|
+
* ```typescript
|
|
300
|
+
* const oracleData = await contract.getOracleData();
|
|
301
|
+
* ```
|
|
302
|
+
*/
|
|
303
|
+
getOracleData: () => Promise<{
|
|
304
|
+
contentNumber: number;
|
|
305
|
+
ownershipNumber: number;
|
|
306
|
+
}>;
|
|
307
|
+
/**
|
|
308
|
+
* [User]
|
|
309
|
+
*
|
|
310
|
+
* This transaction mints a user token which can be used to represent the ownership of the content. This token is used in `createContent()` transaction.
|
|
311
|
+
*
|
|
312
|
+
* @param tokenName - The name of the token that you can specify.
|
|
313
|
+
* @param tokenMetadata - The metadata of the token that you can specify.
|
|
314
|
+
* @returns {Promise<string>}
|
|
315
|
+
*
|
|
316
|
+
* @example
|
|
317
|
+
* ```typescript
|
|
318
|
+
* const tx = await contract.mintUserToken("MeshContentOwnership", {
|
|
319
|
+
* name: "Mesh Content Ownership",
|
|
320
|
+
* description: "Demo at https://meshjs.dev/smart-contracts/content-ownership",
|
|
321
|
+
* });
|
|
322
|
+
* const signedTx = await wallet.signTx(tx, true);
|
|
323
|
+
* const txHash = await wallet.submitTx(signedTx);
|
|
324
|
+
*/
|
|
325
|
+
mintUserToken: (tokenName: string, tokenMetadata?: {}) => Promise<string>;
|
|
326
|
+
/**
|
|
327
|
+
*
|
|
328
|
+
* @param ownerAssetHex
|
|
329
|
+
* @param contentHashHex
|
|
330
|
+
* @param registryNumber
|
|
331
|
+
* @returns
|
|
332
|
+
*/
|
|
156
333
|
createContent: (ownerAssetHex: string, contentHashHex: string, registryNumber?: number) => Promise<string>;
|
|
334
|
+
/**
|
|
335
|
+
* Get the content at the registry given the registry number and content number.
|
|
336
|
+
* @param registryNumber
|
|
337
|
+
* @param contentNumber
|
|
338
|
+
* @returns
|
|
339
|
+
*/
|
|
340
|
+
getContent: (registryNumber: number, contentNumber: number) => Promise<string>;
|
|
157
341
|
updateContent: ({ ownerTokenUtxo, registryNumber, newContentHashHex, contentNumber, }: UpdateContent) => Promise<string>;
|
|
158
342
|
transferContent: ({ ownerTokenUtxo, registryNumber, newOwnerAssetHex, contentNumber, }: TransferContent) => Promise<string>;
|
|
159
343
|
stopContentRegistry: (registryNumber: number) => Promise<string>;
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// src/content-ownership/offchain/offchain.ts
|
|
2
2
|
import {
|
|
3
|
-
deserializeAddress
|
|
3
|
+
deserializeAddress,
|
|
4
|
+
ForgeScript,
|
|
4
5
|
mConStr,
|
|
5
6
|
mConStr0,
|
|
6
7
|
mConStr1,
|
|
@@ -8,9 +9,14 @@ import {
|
|
|
8
9
|
mScriptAddress,
|
|
9
10
|
resolveScriptHash as resolveScriptHash2,
|
|
10
11
|
serializeNativeScript,
|
|
11
|
-
stringToHex
|
|
12
|
+
stringToHex,
|
|
13
|
+
toUTF8
|
|
12
14
|
} from "@meshsdk/core";
|
|
13
|
-
import {
|
|
15
|
+
import {
|
|
16
|
+
applyParamsToScript as applyParamsToScript2,
|
|
17
|
+
parseDatumCbor,
|
|
18
|
+
parseInlineDatum
|
|
19
|
+
} from "@meshsdk/core-csl";
|
|
14
20
|
|
|
15
21
|
// src/common.ts
|
|
16
22
|
import {
|
|
@@ -942,11 +948,11 @@ var MeshContentOwnershipContract = class extends MeshTxInitiator {
|
|
|
942
948
|
this.networkId
|
|
943
949
|
);
|
|
944
950
|
this.operationAddress = contract.operationAddress;
|
|
945
|
-
const serializedOpsPlutusAddr =
|
|
951
|
+
const serializedOpsPlutusAddr = deserializeAddress(this.operationAddress);
|
|
946
952
|
this.opsKey = serializedOpsPlutusAddr.pubKeyHash;
|
|
947
953
|
}
|
|
948
954
|
getOwnerNativeScript = () => {
|
|
949
|
-
const { pubKeyHash: keyHash } =
|
|
955
|
+
const { pubKeyHash: keyHash } = deserializeAddress(this.operationAddress);
|
|
950
956
|
const nativeScript = {
|
|
951
957
|
type: "all",
|
|
952
958
|
scripts: [
|
|
@@ -966,7 +972,24 @@ var MeshContentOwnershipContract = class extends MeshTxInitiator {
|
|
|
966
972
|
scriptAddress
|
|
967
973
|
};
|
|
968
974
|
};
|
|
969
|
-
|
|
975
|
+
/**
|
|
976
|
+
* [Setup phase]
|
|
977
|
+
* This is the first transaction you need to setup the contract.
|
|
978
|
+
*
|
|
979
|
+
* This transaction mints the one-time minting policy (a NFT) for the contract.
|
|
980
|
+
* It will be attached with the datum which serves as the single source of truth for the contract oracle.
|
|
981
|
+
*
|
|
982
|
+
* Note: You must save the `paramUtxo` for future transactions.
|
|
983
|
+
*
|
|
984
|
+
* @returns {Promise<{ txHexMintOneTimeMintingPolicy: string, txHexSetupOracleUtxo: string, paramUtxo: UTxO["input"] }>}
|
|
985
|
+
*
|
|
986
|
+
* @example
|
|
987
|
+
* ```typescript
|
|
988
|
+
* const { tx, paramUtxo } = await contract.mintOneTimeMintingPolicy();
|
|
989
|
+
* const signedTx = await wallet.signTx(tx);
|
|
990
|
+
* const txHash = await wallet.submitTx(signedTx);
|
|
991
|
+
* ```
|
|
992
|
+
*/
|
|
970
993
|
mintOneTimeMintingPolicy = async () => {
|
|
971
994
|
const { utxos, collateral, walletAddress } = await this.getWalletInfoForTx();
|
|
972
995
|
if (utxos?.length <= 0) {
|
|
@@ -997,14 +1020,27 @@ var MeshContentOwnershipContract = class extends MeshTxInitiator {
|
|
|
997
1020
|
this.stakeCredential,
|
|
998
1021
|
this.networkId
|
|
999
1022
|
);
|
|
1023
|
+
this.paramUtxo = paramUtxo.input;
|
|
1000
1024
|
return { tx: txHex, paramUtxo: paramUtxo.input };
|
|
1001
1025
|
};
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1026
|
+
/**
|
|
1027
|
+
* [Setup phase]
|
|
1028
|
+
* This is the second transaction you need to setup the contract.
|
|
1029
|
+
*
|
|
1030
|
+
* This transaction send the NFT to a oracle contract locking the datum,
|
|
1031
|
+
* which serves as the single source of truth for the contract oracle with data integrity.
|
|
1032
|
+
*
|
|
1033
|
+
* Note: You must provide the `paramUtxo` from the `mintOneTimeMintingPolicy` transaction.
|
|
1034
|
+
*
|
|
1035
|
+
* @returns {Promise<string>}
|
|
1036
|
+
*
|
|
1037
|
+
* @example
|
|
1038
|
+
* ```typescript
|
|
1039
|
+
* const txHex = await contract.setupOracleUtxo();
|
|
1040
|
+
* const signedTx = await wallet.signTx(txHex);
|
|
1041
|
+
* const txHash = await wallet.submitTx(signedTx);
|
|
1042
|
+
* ```
|
|
1043
|
+
*/
|
|
1008
1044
|
setupOracleUtxo = async () => {
|
|
1009
1045
|
const { utxos, walletAddress } = await this.getWalletInfoForTx();
|
|
1010
1046
|
const datumValue = this.getOracleDatum(0, 0);
|
|
@@ -1013,22 +1049,60 @@ var MeshContentOwnershipContract = class extends MeshTxInitiator {
|
|
|
1013
1049
|
]).txOutInlineDatumValue(datumValue).changeAddress(walletAddress).selectUtxosFrom(utxos).complete();
|
|
1014
1050
|
return txHex;
|
|
1015
1051
|
};
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1052
|
+
/**
|
|
1053
|
+
* [Setup phase]
|
|
1054
|
+
* This are the next transactions you need to setup the contract.
|
|
1055
|
+
* You need to run once for each script, and you would likely have to run one after the previous one is confirmed.
|
|
1056
|
+
*
|
|
1057
|
+
* This transaction sends the reference scripts to the blockchain for later transactions,
|
|
1058
|
+
* boosting efficiency and avoid exceeding 16kb of transaction size limits enforced by protocol parameter.
|
|
1059
|
+
*
|
|
1060
|
+
* Note: You must provide the `paramUtxo` from the `mintOneTimeMintingPolicy` transaction.
|
|
1061
|
+
* Note: You must save txHash (after signed and submitted) for `ContentRegistry`, `ContentRefToken`, `OwnershipRegistry`, `OwnershipRefToken` transactions for future transactions.
|
|
1062
|
+
*
|
|
1063
|
+
* @param scriptIndex - "OracleNFT" | "OracleValidator" | "ContentRegistry" | "ContentRefToken" | "OwnershipRegistry" | "OwnershipRefToken"
|
|
1064
|
+
* @returns {Promise<string>}
|
|
1065
|
+
*
|
|
1066
|
+
* @example
|
|
1067
|
+
* ```typescript
|
|
1068
|
+
* const txHexOracleNFT = await contract.sendRefScriptOnchain("OracleNFT");
|
|
1069
|
+
* const signedTxOracleNFT = await wallet.signTx(txHexOracleNFT);
|
|
1070
|
+
* const txHashOracleNFT = await wallet.submitTx(signedTxOracleNFT);
|
|
1071
|
+
*
|
|
1072
|
+
* const txHexOracleValidator = await contract.sendRefScriptOnchain("OracleValidator");
|
|
1073
|
+
* ... // repeat for each script
|
|
1074
|
+
*
|
|
1075
|
+
* const txHexOwnershipRefToken = await contract.sendRefScriptOnchain("OwnershipRefToken");
|
|
1076
|
+
* const signedTxOwnershipRefToken = await wallet.signTx(txHexOwnershipRefToken);
|
|
1077
|
+
* const txHashOwnershipRefToken = await wallet.submitTx(signedTxOwnershipRefToken);
|
|
1078
|
+
* ```
|
|
1079
|
+
*/
|
|
1080
|
+
sendRefScriptOnchain = async (scriptIndex) => {
|
|
1081
|
+
const { utxos, walletAddress } = await this.getWalletInfoForTx();
|
|
1082
|
+
const { scriptAddress } = this.getOwnerNativeScript();
|
|
1083
|
+
const txHex = await this.mesh.txOut(scriptAddress, []).txOutReferenceScript(getScriptCbor(this.paramUtxo, scriptIndex)).changeAddress(walletAddress).selectUtxosFrom(utxos, "experimental", "20000000").complete();
|
|
1084
|
+
return txHex;
|
|
1031
1085
|
};
|
|
1086
|
+
/**
|
|
1087
|
+
* [Setup phase]
|
|
1088
|
+
* This is the next transaction you need to setup the contract after completing all the `sendRefScriptOnchain` transactions.
|
|
1089
|
+
*
|
|
1090
|
+
* This transaction creates one content registry. Each registry should comes in pair with one ownership registry and
|
|
1091
|
+
* each pair of registry serves around 50 records of content ownership. The application can be scaled indefinitely
|
|
1092
|
+
* according to the number of parallelization needed and volumes of content expected to be managed.
|
|
1093
|
+
*
|
|
1094
|
+
* Note: You must provide the `paramUtxo` from the `mintOneTimeMintingPolicy` transaction.
|
|
1095
|
+
* Note: You must provide the txHash for `ContentRegistry`, `ContentRefToken`, `OwnershipRegistry`, `OwnershipRefToken`
|
|
1096
|
+
*
|
|
1097
|
+
* @returns {Promise<string>}
|
|
1098
|
+
*
|
|
1099
|
+
* @example
|
|
1100
|
+
* ```typescript
|
|
1101
|
+
* const txHex = await contract.createContentRegistry();
|
|
1102
|
+
* const signedTx = await wallet.signTx(txHex);
|
|
1103
|
+
* const txHash = await wallet.submitTx(signedTx);
|
|
1104
|
+
* ```
|
|
1105
|
+
*/
|
|
1032
1106
|
createContentRegistry = async () => {
|
|
1033
1107
|
const { utxos, collateral, walletAddress } = await this.getWalletInfoForTx();
|
|
1034
1108
|
const scriptUtxo = await this.fetcher.fetchAddressUTxOs(
|
|
@@ -1069,6 +1143,26 @@ var MeshContentOwnershipContract = class extends MeshTxInitiator {
|
|
|
1069
1143
|
).changeAddress(walletAddress).selectUtxosFrom(utxos, "largestFirstMultiAsset").complete();
|
|
1070
1144
|
return txHex;
|
|
1071
1145
|
};
|
|
1146
|
+
/**
|
|
1147
|
+
* [Setup phase]
|
|
1148
|
+
* This is the last transaction you need to setup the contract after completing all the `sendRefScriptOnchain` transactions.
|
|
1149
|
+
*
|
|
1150
|
+
* This transaction creates one content registry. Each registry should comes in pair with one content registry and
|
|
1151
|
+
* each pair of registry serves around 50 records of content ownership. The application can be scaled indefinitely
|
|
1152
|
+
* according to the number of parallelization needed and volumes of content expected to be managed.
|
|
1153
|
+
*
|
|
1154
|
+
* Note: You must provide the `paramUtxo` from the `mintOneTimeMintingPolicy` transaction.
|
|
1155
|
+
* Note: You must provide the txHash for `ContentRegistry`, `ContentRefToken`, `OwnershipRegistry`, `OwnershipRefToken`
|
|
1156
|
+
*
|
|
1157
|
+
* @returns {Promise<string>}
|
|
1158
|
+
*
|
|
1159
|
+
* @example
|
|
1160
|
+
* ```typescript
|
|
1161
|
+
* const txHex = await contract.createOwnershipRegistry();
|
|
1162
|
+
* const signedTx = await wallet.signTx(txHex);
|
|
1163
|
+
* const txHash = await wallet.submitTx(signedTx);
|
|
1164
|
+
* ```
|
|
1165
|
+
*/
|
|
1072
1166
|
createOwnershipRegistry = async () => {
|
|
1073
1167
|
const { utxos, collateral, walletAddress } = await this.getWalletInfoForTx();
|
|
1074
1168
|
const scriptUtxo = await this.fetcher.fetchAddressUTxOs(
|
|
@@ -1105,10 +1199,79 @@ var MeshContentOwnershipContract = class extends MeshTxInitiator {
|
|
|
1105
1199
|
collateral.input.outputIndex,
|
|
1106
1200
|
collateral.output.amount,
|
|
1107
1201
|
collateral.output.address
|
|
1108
|
-
).changeAddress(walletAddress).selectUtxosFrom(utxos).complete();
|
|
1202
|
+
).changeAddress(walletAddress).selectUtxosFrom(utxos, "largestFirstMultiAsset").complete();
|
|
1109
1203
|
return txHex;
|
|
1110
1204
|
};
|
|
1111
|
-
|
|
1205
|
+
/**
|
|
1206
|
+
* Get the current oracle data.
|
|
1207
|
+
*
|
|
1208
|
+
* @returns {Promise<{
|
|
1209
|
+
* contentNumber: number,
|
|
1210
|
+
* ownershipNumber: number,
|
|
1211
|
+
* }>}
|
|
1212
|
+
*
|
|
1213
|
+
* @example
|
|
1214
|
+
* ```typescript
|
|
1215
|
+
* const oracleData = await contract.getOracleData();
|
|
1216
|
+
* ```
|
|
1217
|
+
*/
|
|
1218
|
+
getOracleData = async () => {
|
|
1219
|
+
const scriptUtxo = await this.fetcher.fetchAddressUTxOs(
|
|
1220
|
+
this.scriptInfo.oracleValidator.address,
|
|
1221
|
+
this.scriptInfo.oracleNFT.hash
|
|
1222
|
+
);
|
|
1223
|
+
const currentOracleDatum = await this.getCurrentOracleDatum(scriptUtxo);
|
|
1224
|
+
const contentNumber = currentOracleDatum.fields[4].int;
|
|
1225
|
+
const ownershipNumber = currentOracleDatum.fields[7].int;
|
|
1226
|
+
return {
|
|
1227
|
+
contentNumber,
|
|
1228
|
+
ownershipNumber
|
|
1229
|
+
};
|
|
1230
|
+
};
|
|
1231
|
+
/**
|
|
1232
|
+
* [User]
|
|
1233
|
+
*
|
|
1234
|
+
* This transaction mints a user token which can be used to represent the ownership of the content. This token is used in `createContent()` transaction.
|
|
1235
|
+
*
|
|
1236
|
+
* @param tokenName - The name of the token that you can specify.
|
|
1237
|
+
* @param tokenMetadata - The metadata of the token that you can specify.
|
|
1238
|
+
* @returns {Promise<string>}
|
|
1239
|
+
*
|
|
1240
|
+
* @example
|
|
1241
|
+
* ```typescript
|
|
1242
|
+
* const tx = await contract.mintUserToken("MeshContentOwnership", {
|
|
1243
|
+
* name: "Mesh Content Ownership",
|
|
1244
|
+
* description: "Demo at https://meshjs.dev/smart-contracts/content-ownership",
|
|
1245
|
+
* });
|
|
1246
|
+
* const signedTx = await wallet.signTx(tx, true);
|
|
1247
|
+
* const txHash = await wallet.submitTx(signedTx);
|
|
1248
|
+
*/
|
|
1249
|
+
mintUserToken = async (tokenName2, tokenMetadata = {}) => {
|
|
1250
|
+
const { utxos, walletAddress } = await this.getWalletInfoForTx();
|
|
1251
|
+
const { pubKeyHash: keyHash } = deserializeAddress(walletAddress);
|
|
1252
|
+
const nativeScript = {
|
|
1253
|
+
type: "all",
|
|
1254
|
+
scripts: [
|
|
1255
|
+
{
|
|
1256
|
+
type: "sig",
|
|
1257
|
+
keyHash
|
|
1258
|
+
}
|
|
1259
|
+
]
|
|
1260
|
+
};
|
|
1261
|
+
const forgingScript = ForgeScript.fromNativeScript(nativeScript);
|
|
1262
|
+
const policyId = resolveScriptHash2(forgingScript);
|
|
1263
|
+
const tokenNameHex = stringToHex(tokenName2);
|
|
1264
|
+
const metadata = { [policyId]: { [tokenName2]: { ...tokenMetadata } } };
|
|
1265
|
+
const txHex = await this.mesh.mint("1", policyId, tokenNameHex).mintingScript(forgingScript).metadataValue("721", metadata).changeAddress(walletAddress).selectUtxosFrom(utxos).complete();
|
|
1266
|
+
return txHex;
|
|
1267
|
+
};
|
|
1268
|
+
/**
|
|
1269
|
+
*
|
|
1270
|
+
* @param ownerAssetHex
|
|
1271
|
+
* @param contentHashHex
|
|
1272
|
+
* @param registryNumber
|
|
1273
|
+
* @returns
|
|
1274
|
+
*/
|
|
1112
1275
|
createContent = async (ownerAssetHex, contentHashHex, registryNumber = 0) => {
|
|
1113
1276
|
const { utxos, collateral, walletAddress } = await this.getWalletInfoForTx();
|
|
1114
1277
|
const registryName = stringToHex(`Registry (${registryNumber})`);
|
|
@@ -1178,6 +1341,24 @@ var MeshContentOwnershipContract = class extends MeshTxInitiator {
|
|
|
1178
1341
|
).selectUtxosFrom(utxos).complete();
|
|
1179
1342
|
return txHex;
|
|
1180
1343
|
};
|
|
1344
|
+
/**
|
|
1345
|
+
* Get the content at the registry given the registry number and content number.
|
|
1346
|
+
* @param registryNumber
|
|
1347
|
+
* @param contentNumber
|
|
1348
|
+
* @returns
|
|
1349
|
+
*/
|
|
1350
|
+
getContent = async (registryNumber, contentNumber) => {
|
|
1351
|
+
const [content] = await this.getScriptUtxos(registryNumber, ["content"]);
|
|
1352
|
+
if (content === void 0) throw new Error("Content registry not found");
|
|
1353
|
+
const contentDatam = parseDatumCbor(
|
|
1354
|
+
content.output.plutusData
|
|
1355
|
+
);
|
|
1356
|
+
const contentAtRegistry = contentDatam.fields[1].list;
|
|
1357
|
+
if (contentAtRegistry.length <= contentNumber)
|
|
1358
|
+
throw new Error("Content not found");
|
|
1359
|
+
const decoded = toUTF8(contentAtRegistry[contentNumber]?.bytes);
|
|
1360
|
+
return decoded;
|
|
1361
|
+
};
|
|
1181
1362
|
updateContent = async ({
|
|
1182
1363
|
ownerTokenUtxo,
|
|
1183
1364
|
registryNumber,
|
|
@@ -1487,7 +1668,7 @@ import {
|
|
|
1487
1668
|
value
|
|
1488
1669
|
} from "@meshsdk/common";
|
|
1489
1670
|
import {
|
|
1490
|
-
deserializeAddress as
|
|
1671
|
+
deserializeAddress as deserializeAddress2,
|
|
1491
1672
|
deserializeDatum,
|
|
1492
1673
|
mergeAssets,
|
|
1493
1674
|
serializeAddressObj
|
|
@@ -2022,14 +2203,14 @@ var plutus_default3 = {
|
|
|
2022
2203
|
|
|
2023
2204
|
// src/escrow/offchain.ts
|
|
2024
2205
|
var initiateEscrowDatum = (walletAddress, amount) => {
|
|
2025
|
-
const { pubKeyHash, stakeCredentialHash } =
|
|
2206
|
+
const { pubKeyHash, stakeCredentialHash } = deserializeAddress2(walletAddress);
|
|
2026
2207
|
return conStr0([
|
|
2027
2208
|
pubKeyAddress(pubKeyHash, stakeCredentialHash),
|
|
2028
2209
|
value(amount)
|
|
2029
2210
|
]);
|
|
2030
2211
|
};
|
|
2031
2212
|
var activeEscrowDatum = (initiationDatum, walletAddress, amount) => {
|
|
2032
|
-
const { pubKeyHash, stakeCredentialHash } =
|
|
2213
|
+
const { pubKeyHash, stakeCredentialHash } = deserializeAddress2(walletAddress);
|
|
2033
2214
|
const [initiator, initiatorAmount] = initiationDatum.fields;
|
|
2034
2215
|
return conStr1([
|
|
2035
2216
|
initiator,
|
|
@@ -2094,7 +2275,7 @@ var MeshEscrowContract = class extends MeshTxInitiator {
|
|
|
2094
2275
|
escrowUtxo.input.outputIndex,
|
|
2095
2276
|
escrowUtxo.output.amount,
|
|
2096
2277
|
this.scriptAddress
|
|
2097
|
-
).spendingReferenceTxInInlineDatumPresent().spendingReferenceTxInRedeemerValue(mConStr12([])).txInScript(this.scriptCbor).requiredSignerHash(
|
|
2278
|
+
).spendingReferenceTxInInlineDatumPresent().spendingReferenceTxInRedeemerValue(mConStr12([])).txInScript(this.scriptCbor).requiredSignerHash(deserializeAddress2(walletAddress).pubKeyHash).changeAddress(walletAddress).txInCollateral(
|
|
2098
2279
|
collateral.input.txHash,
|
|
2099
2280
|
collateral.input.outputIndex,
|
|
2100
2281
|
collateral.output.amount,
|
|
@@ -2157,7 +2338,7 @@ var MeshEscrowContract = class extends MeshTxInitiator {
|
|
|
2157
2338
|
escrowUtxo.input.outputIndex,
|
|
2158
2339
|
escrowUtxo.output.amount,
|
|
2159
2340
|
this.scriptAddress
|
|
2160
|
-
).spendingReferenceTxInInlineDatumPresent().spendingReferenceTxInRedeemerValue(mConStr2([])).txInScript(this.scriptCbor).txOut(initiatorAddress, initiatorToReceive).txOut(recipientAddress, recipientToReceive).requiredSignerHash(
|
|
2341
|
+
).spendingReferenceTxInInlineDatumPresent().spendingReferenceTxInRedeemerValue(mConStr2([])).txInScript(this.scriptCbor).txOut(initiatorAddress, initiatorToReceive).txOut(recipientAddress, recipientToReceive).requiredSignerHash(deserializeAddress2(recipientAddress).pubKeyHash).requiredSignerHash(deserializeAddress2(initiatorAddress).pubKeyHash).changeAddress(walletAddress).txInCollateral(
|
|
2161
2342
|
collateral.input.txHash,
|
|
2162
2343
|
collateral.input.outputIndex,
|
|
2163
2344
|
collateral.output.amount,
|
|
@@ -2172,7 +2353,7 @@ var MeshEscrowContract = class extends MeshTxInitiator {
|
|
|
2172
2353
|
|
|
2173
2354
|
// src/giftcard/offchain.ts
|
|
2174
2355
|
import {
|
|
2175
|
-
builtinByteString as
|
|
2356
|
+
builtinByteString as builtinByteString3,
|
|
2176
2357
|
mConStr0 as mConStr02,
|
|
2177
2358
|
mConStr1 as mConStr13,
|
|
2178
2359
|
outputReference as outputReference2,
|
|
@@ -2514,7 +2695,7 @@ var MeshGiftCardContract = class extends MeshTxInitiator {
|
|
|
2514
2695
|
}
|
|
2515
2696
|
return applyParamsToScript4(
|
|
2516
2697
|
scriptCbor,
|
|
2517
|
-
[
|
|
2698
|
+
[builtinByteString3(tokenNameHex), utxo],
|
|
2518
2699
|
"JSON"
|
|
2519
2700
|
);
|
|
2520
2701
|
};
|
|
@@ -2609,7 +2790,7 @@ var MeshGiftCardContract = class extends MeshTxInitiator {
|
|
|
2609
2790
|
|
|
2610
2791
|
// src/hello-world/offchain.ts
|
|
2611
2792
|
import {
|
|
2612
|
-
deserializeAddress as
|
|
2793
|
+
deserializeAddress as deserializeAddress3,
|
|
2613
2794
|
mConStr0 as mConStr03,
|
|
2614
2795
|
stringToHex as stringToHex3
|
|
2615
2796
|
} from "@meshsdk/core";
|
|
@@ -2785,13 +2966,13 @@ var MeshHelloWorldContract = class extends MeshTxInitiator {
|
|
|
2785
2966
|
};
|
|
2786
2967
|
lockAsset = async (assets) => {
|
|
2787
2968
|
const { utxos, walletAddress } = await this.getWalletInfoForTx();
|
|
2788
|
-
const signerHash =
|
|
2969
|
+
const signerHash = deserializeAddress3(walletAddress).pubKeyHash;
|
|
2789
2970
|
await this.mesh.txOut(this.scriptAddress, assets).txOutDatumHashValue(mConStr03([signerHash])).changeAddress(walletAddress).selectUtxosFrom(utxos).complete();
|
|
2790
2971
|
return this.mesh.txHex;
|
|
2791
2972
|
};
|
|
2792
2973
|
unlockAsset = async (scriptUtxo, message) => {
|
|
2793
2974
|
const { utxos, walletAddress, collateral } = await this.getWalletInfoForTx();
|
|
2794
|
-
const signerHash =
|
|
2975
|
+
const signerHash = deserializeAddress3(walletAddress).pubKeyHash;
|
|
2795
2976
|
await this.mesh.spendingPlutusScript(this.languageVersion).txIn(
|
|
2796
2977
|
scriptUtxo.input.txHash,
|
|
2797
2978
|
scriptUtxo.input.outputIndex,
|
|
@@ -2822,7 +3003,7 @@ import {
|
|
|
2822
3003
|
tokenName
|
|
2823
3004
|
} from "@meshsdk/common";
|
|
2824
3005
|
import {
|
|
2825
|
-
deserializeAddress as
|
|
3006
|
+
deserializeAddress as deserializeAddress4,
|
|
2826
3007
|
deserializeDatum as deserializeDatum3,
|
|
2827
3008
|
serializeAddressObj as serializeAddressObj2
|
|
2828
3009
|
} from "@meshsdk/core";
|
|
@@ -3295,7 +3476,7 @@ var plutus_default9 = {
|
|
|
3295
3476
|
|
|
3296
3477
|
// src/marketplace/offchain.ts
|
|
3297
3478
|
var marketplaceDatum = (sellerAddress, lovelaceFee, assetHex) => {
|
|
3298
|
-
const { pubKeyHash, stakeCredentialHash } =
|
|
3479
|
+
const { pubKeyHash, stakeCredentialHash } = deserializeAddress4(sellerAddress);
|
|
3299
3480
|
const { policyId, assetName } = parseAssetUnit(assetHex);
|
|
3300
3481
|
return conStr02([
|
|
3301
3482
|
pubKeyAddress2(pubKeyHash, stakeCredentialHash),
|
|
@@ -3313,7 +3494,7 @@ var MeshMarketplaceContract = class extends MeshTxInitiator {
|
|
|
3313
3494
|
super(inputs);
|
|
3314
3495
|
this.ownerAddress = ownerAddress;
|
|
3315
3496
|
this.feePercentageBasisPoint = feePercentageBasisPoint;
|
|
3316
|
-
const { pubKeyHash, stakeCredentialHash } =
|
|
3497
|
+
const { pubKeyHash, stakeCredentialHash } = deserializeAddress4(ownerAddress);
|
|
3317
3498
|
this.scriptCbor = this.getScriptCbor(
|
|
3318
3499
|
pubKeyHash,
|
|
3319
3500
|
stakeCredentialHash,
|
|
@@ -3359,7 +3540,7 @@ var MeshMarketplaceContract = class extends MeshTxInitiator {
|
|
|
3359
3540
|
marketplaceUtxo.input.outputIndex,
|
|
3360
3541
|
marketplaceUtxo.output.amount,
|
|
3361
3542
|
marketplaceUtxo.output.address
|
|
3362
|
-
).spendingReferenceTxInInlineDatumPresent().spendingReferenceTxInRedeemerValue(mConStr14([])).txInScript(this.scriptCbor).changeAddress(walletAddress).requiredSignerHash(
|
|
3543
|
+
).spendingReferenceTxInInlineDatumPresent().spendingReferenceTxInRedeemerValue(mConStr14([])).txInScript(this.scriptCbor).changeAddress(walletAddress).requiredSignerHash(deserializeAddress4(walletAddress).pubKeyHash).txInCollateral(
|
|
3363
3544
|
collateral.input.txHash,
|
|
3364
3545
|
collateral.input.outputIndex,
|
|
3365
3546
|
collateral.output.amount,
|
|
@@ -3428,7 +3609,7 @@ var MeshMarketplaceContract = class extends MeshTxInitiator {
|
|
|
3428
3609
|
marketplaceUtxo.input.outputIndex,
|
|
3429
3610
|
marketplaceUtxo.output.amount,
|
|
3430
3611
|
marketplaceUtxo.output.address
|
|
3431
|
-
).spendingReferenceTxInInlineDatumPresent().spendingReferenceTxInRedeemerValue(mConStr14([])).txInScript(this.scriptCbor).txOut(this.scriptAddress, tokenForSale).txOutInlineDatumValue(outputDatum, "JSON").changeAddress(walletAddress).requiredSignerHash(
|
|
3612
|
+
).spendingReferenceTxInInlineDatumPresent().spendingReferenceTxInRedeemerValue(mConStr14([])).txInScript(this.scriptCbor).txOut(this.scriptAddress, tokenForSale).txOutInlineDatumValue(outputDatum, "JSON").changeAddress(walletAddress).requiredSignerHash(deserializeAddress4(walletAddress).pubKeyHash).txInCollateral(
|
|
3432
3613
|
collateral.input.txHash,
|
|
3433
3614
|
collateral.input.outputIndex,
|
|
3434
3615
|
collateral.output.amount,
|
|
@@ -3450,10 +3631,10 @@ var MeshMarketplaceContract = class extends MeshTxInitiator {
|
|
|
3450
3631
|
};
|
|
3451
3632
|
|
|
3452
3633
|
// src/payment-splitter/offchain.ts
|
|
3453
|
-
import { builtinByteString as
|
|
3634
|
+
import { builtinByteString as builtinByteString4, list } from "@meshsdk/common";
|
|
3454
3635
|
import {
|
|
3455
3636
|
BrowserWallet as BrowserWallet2,
|
|
3456
|
-
deserializeAddress as
|
|
3637
|
+
deserializeAddress as deserializeAddress5,
|
|
3457
3638
|
MeshWallet as MeshWallet2,
|
|
3458
3639
|
Transaction
|
|
3459
3640
|
} from "@meshsdk/core";
|
|
@@ -3653,7 +3834,7 @@ var MeshPaymentSplitterContract = class extends MeshTxInitiator {
|
|
|
3653
3834
|
payees = [];
|
|
3654
3835
|
wrapPayees = (payees) => list(
|
|
3655
3836
|
payees.map(
|
|
3656
|
-
(payee) =>
|
|
3837
|
+
(payee) => builtinByteString4(deserializeAddress5(payee).pubKeyHash)
|
|
3657
3838
|
)
|
|
3658
3839
|
);
|
|
3659
3840
|
constructor(inputs, payees) {
|
|
@@ -3697,7 +3878,7 @@ var MeshPaymentSplitterContract = class extends MeshTxInitiator {
|
|
|
3697
3878
|
throw new Error("Wallet not provided");
|
|
3698
3879
|
}
|
|
3699
3880
|
const { walletAddress } = await this.getWalletInfoForTx();
|
|
3700
|
-
const { pubKeyHash } =
|
|
3881
|
+
const { pubKeyHash } = deserializeAddress5(walletAddress);
|
|
3701
3882
|
const datum = {
|
|
3702
3883
|
alternative: 0,
|
|
3703
3884
|
fields: [pubKeyHash]
|
|
@@ -3722,7 +3903,7 @@ var MeshPaymentSplitterContract = class extends MeshTxInitiator {
|
|
|
3722
3903
|
version: this.languageVersion
|
|
3723
3904
|
};
|
|
3724
3905
|
const utxos = await this.fetcher?.fetchAddressUTxOs(this.scriptAddress) || [];
|
|
3725
|
-
const { pubKeyHash } =
|
|
3906
|
+
const { pubKeyHash } = deserializeAddress5(walletAddress);
|
|
3726
3907
|
const datum = {
|
|
3727
3908
|
alternative: 0,
|
|
3728
3909
|
fields: [pubKeyHash]
|
|
@@ -3766,7 +3947,7 @@ import {
|
|
|
3766
3947
|
stringToHex as stringToHex4
|
|
3767
3948
|
} from "@meshsdk/common";
|
|
3768
3949
|
import {
|
|
3769
|
-
deserializeAddress as
|
|
3950
|
+
deserializeAddress as deserializeAddress6,
|
|
3770
3951
|
resolveScriptHash as resolveScriptHash4,
|
|
3771
3952
|
serializeAddressObj as serializeAddressObj3,
|
|
3772
3953
|
serializePlutusScript as serializePlutusScript3
|
|
@@ -3774,7 +3955,7 @@ import {
|
|
|
3774
3955
|
import {
|
|
3775
3956
|
applyCborEncoding,
|
|
3776
3957
|
applyParamsToScript as applyParamsToScript8,
|
|
3777
|
-
parseDatumCbor
|
|
3958
|
+
parseDatumCbor as parseDatumCbor2
|
|
3778
3959
|
} from "@meshsdk/core-csl";
|
|
3779
3960
|
|
|
3780
3961
|
// src/plutus-nft/aiken-workspace/plutus.json
|
|
@@ -4207,7 +4388,7 @@ var MeshPlutusNFTContract = class extends MeshTxInitiator {
|
|
|
4207
4388
|
const paramScript = applyParamsToScript8(script, [param]);
|
|
4208
4389
|
const policyId = resolveScriptHash4(paramScript, "V3");
|
|
4209
4390
|
const tokenName2 = "";
|
|
4210
|
-
const { pubKeyHash, stakeCredentialHash } =
|
|
4391
|
+
const { pubKeyHash, stakeCredentialHash } = deserializeAddress6(walletAddress);
|
|
4211
4392
|
const txHex = await this.mesh.txIn(
|
|
4212
4393
|
paramUtxo.input.txHash,
|
|
4213
4394
|
paramUtxo.input.outputIndex,
|
|
@@ -4297,7 +4478,7 @@ var MeshPlutusNFTContract = class extends MeshTxInitiator {
|
|
|
4297
4478
|
getOracleData = async () => {
|
|
4298
4479
|
const oracleNftPolicyId = resolveScriptHash4(this.getOracleNFTCbor(), "V3");
|
|
4299
4480
|
const oracleUtxo = (await this.getAddressUtxosWithToken(this.oracleAddress, oracleNftPolicyId))[0];
|
|
4300
|
-
const oracleDatum =
|
|
4481
|
+
const oracleDatum = parseDatumCbor2(
|
|
4301
4482
|
oracleUtxo.output.plutusData
|
|
4302
4483
|
);
|
|
4303
4484
|
const nftIndex = oracleDatum.fields[0].int;
|
|
@@ -4333,7 +4514,7 @@ import {
|
|
|
4333
4514
|
value as value2
|
|
4334
4515
|
} from "@meshsdk/common";
|
|
4335
4516
|
import {
|
|
4336
|
-
deserializeAddress as
|
|
4517
|
+
deserializeAddress as deserializeAddress7,
|
|
4337
4518
|
deserializeDatum as deserializeDatum4,
|
|
4338
4519
|
serializeAddressObj as serializeAddressObj4
|
|
4339
4520
|
} from "@meshsdk/core";
|
|
@@ -4816,7 +4997,7 @@ var MeshSwapContract = class extends MeshTxInitiator {
|
|
|
4816
4997
|
};
|
|
4817
4998
|
initiateSwap = async (toProvide, toReceive) => {
|
|
4818
4999
|
const { utxos, walletAddress, collateral } = await this.getWalletInfoForTx();
|
|
4819
|
-
const { pubKeyHash, stakeCredentialHash } =
|
|
5000
|
+
const { pubKeyHash, stakeCredentialHash } = deserializeAddress7(walletAddress);
|
|
4820
5001
|
const swapDatum = conStr04([
|
|
4821
5002
|
pubKeyAddress3(pubKeyHash, stakeCredentialHash),
|
|
4822
5003
|
value2(toProvide),
|
|
@@ -4875,7 +5056,7 @@ var MeshSwapContract = class extends MeshTxInitiator {
|
|
|
4875
5056
|
collateral.input.outputIndex,
|
|
4876
5057
|
collateral.output.amount,
|
|
4877
5058
|
collateral.output.address
|
|
4878
|
-
).requiredSignerHash(
|
|
5059
|
+
).requiredSignerHash(deserializeAddress7(initiatorAddress).pubKeyHash).selectUtxosFrom(utxos).complete();
|
|
4879
5060
|
return this.mesh.txHex;
|
|
4880
5061
|
};
|
|
4881
5062
|
getUtxoByTxHash = async (txHash) => {
|
|
@@ -4890,7 +5071,7 @@ import {
|
|
|
4890
5071
|
unixTimeToEnclosingSlot
|
|
4891
5072
|
} from "@meshsdk/common";
|
|
4892
5073
|
import {
|
|
4893
|
-
deserializeAddress as
|
|
5074
|
+
deserializeAddress as deserializeAddress8,
|
|
4894
5075
|
deserializeDatum as deserializeDatum5
|
|
4895
5076
|
} from "@meshsdk/core";
|
|
4896
5077
|
import { applyParamsToScript as applyParamsToScript10 } from "@meshsdk/core-csl";
|
|
@@ -5065,8 +5246,8 @@ var MeshVestingContract = class extends MeshTxInitiator {
|
|
|
5065
5246
|
};
|
|
5066
5247
|
depositFund = async (amount, lockUntilTimeStampMs, beneficiary) => {
|
|
5067
5248
|
const { utxos, walletAddress } = await this.getWalletInfoForTx();
|
|
5068
|
-
const { pubKeyHash: ownerPubKeyHash } =
|
|
5069
|
-
const { pubKeyHash: beneficiaryPubKeyHash } =
|
|
5249
|
+
const { pubKeyHash: ownerPubKeyHash } = deserializeAddress8(walletAddress);
|
|
5250
|
+
const { pubKeyHash: beneficiaryPubKeyHash } = deserializeAddress8(beneficiary);
|
|
5070
5251
|
await this.mesh.txOut(this.scriptAddress, amount).txOutInlineDatumValue(
|
|
5071
5252
|
mConStr07([
|
|
5072
5253
|
lockUntilTimeStampMs,
|
|
@@ -5079,7 +5260,7 @@ var MeshVestingContract = class extends MeshTxInitiator {
|
|
|
5079
5260
|
withdrawFund = async (vestingUtxo) => {
|
|
5080
5261
|
const { utxos, walletAddress, collateral } = await this.getWalletInfoForTx();
|
|
5081
5262
|
const { input: collateralInput, output: collateralOutput } = collateral;
|
|
5082
|
-
const { pubKeyHash } =
|
|
5263
|
+
const { pubKeyHash } = deserializeAddress8(walletAddress);
|
|
5083
5264
|
const datum = deserializeDatum5(
|
|
5084
5265
|
vestingUtxo.output.plutusData
|
|
5085
5266
|
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meshsdk/contract",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.11",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"browser": "./dist/index.js",
|
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
"typescript": "^5.3.3"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@meshsdk/common": "1.7.
|
|
38
|
-
"@meshsdk/core": "1.7.
|
|
39
|
-
"@meshsdk/core-csl": "1.7.
|
|
37
|
+
"@meshsdk/common": "1.7.11",
|
|
38
|
+
"@meshsdk/core": "1.7.11",
|
|
39
|
+
"@meshsdk/core-csl": "1.7.11"
|
|
40
40
|
},
|
|
41
41
|
"prettier": "@meshsdk/configs/prettier",
|
|
42
42
|
"publishConfig": {
|