Skip to content

Commit

Permalink
rchain-toolkit 3.0.0 use of deployId instead of prepareDepoy
Browse files Browse the repository at this point in the history
  • Loading branch information
fabcotech committed May 13, 2022
1 parent e1210e0 commit 34d2759
Show file tree
Hide file tree
Showing 32 changed files with 217 additions and 269 deletions.
306 changes: 128 additions & 178 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"test:ft": "node tests-ft/index",
"test:nft": "node tests-nft/index",
"test:credit": "node tests-credit/index",
"dappy:namesystem": "node cli deploy --fungible false --contract-id dappynamesystem && node cli create-purse --new-id 0 --quantity 100000000 && node cli update-purse-price --price n9drev,50000000 --purse-id 0",
"dappy:namesystem": "node cli deploy --fungible false --contract-id dappynamesystem && node cli create-purse --new-id 0 --quantity 100000000 && node cli update-purse-price --price prefixrev,50000000 --purse-id 0",
"dappy:namesystemanddefaults": "npm run dappy:namesystem && node cli create-purse --purses-file name-purses.json"
},
"repository": {
Expand All @@ -27,7 +27,7 @@
"devDependencies": {
"blakejs": "^1.1.0",
"dotenv": "6.2.0",
"@fabcotech/rchain-toolkit": "2.0.0",
"@fabcotech/rchain-toolkit": "3.0.0",
"uuid": "3.4.0",
"rollup": "1.26.0",
"rollup-plugin-commonjs": "^10.1.0",
Expand Down
4 changes: 2 additions & 2 deletions rholang/master.rho
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
new
basket,
deployId(`rho:rchain:deployId`),

prefixCh,
entryCh,
Expand Down Expand Up @@ -1996,7 +1996,7 @@ in {
insertArbitrary!(bundle+{*entryCh}, *entryUriCh) |

for (entryUri <- entryUriCh) {
basket!({
deployId!({
"status": "completed",
"registryUri": *entryUri
}) |
Expand Down
4 changes: 2 additions & 2 deletions rholang/op_create_purses.rho
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* example of creating 5 NFT purses (fungible=false contract) */

new basket,
new deployId(`rho:rchain:deployId`),
itCh,
idsCh,
resultsCh,
Expand All @@ -18,7 +18,7 @@ in {
for (@results <- resultsCh) {
// OP_CREATE_PURSES_COMPLETED_BEGIN
stdout!("completed, purses created, check results to see errors/successes") |
basket!({ "status": "completed", "results": results})
deployId!({ "status": "completed", "results": results})
// OP_CREATE_PURSES_COMPLETED_END
}
}
Expand Down
10 changes: 5 additions & 5 deletions rholang/op_credit.rho
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

new
basket,
deployId(`rho:rchain:deployId`),
revVaultCh,
boxCh,

Expand Down Expand Up @@ -82,7 +82,7 @@ in {
(true, Nil) => {
match "error: purchase failed but was able to refund ${balance} " %% { "balance": balance } ++ r {
s => {
basket!({ "status": "failed", "message": s }) |
deployId!({ "status": "failed", "message": s }) |
stdout!(s)
}
}
Expand All @@ -91,7 +91,7 @@ in {
stdout!(result) |
match "error: CRITICAL purchase failed and was NOT ABLE to refund ${balance} " %% { "balance": balance } ++ r {
s => {
basket!({ "status": "failed", "message": s }) |
deployId!({ "status": "failed", "message": s }) |
stdout!(s)
}
}
Expand All @@ -103,15 +103,15 @@ in {
}
_ => {
// OP_CREDIT_COMPLETED_BEGIN
basket!({ "status": "completed" }) |
deployId!({ "status": "completed" }) |
stdout!("completed, credit successful")
// OP_CREDIT_COMPLETED_END
}
}
}
}
_ => {
basket!({ "status": "failed", "message": result }) |
deployId!({ "status": "failed", "message": result }) |
stdout!(("failed", result))
}
}
Expand Down
6 changes: 3 additions & 3 deletions rholang/op_delete_expired_purse.rho
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
new
basket,
deployId(`rho:rchain:deployId`),
entryCh,
returnCh,
registryLookup(`rho:registry:lookup`),
Expand All @@ -11,13 +11,13 @@ in {
for (@r <- returnCh) {
match r {
String => {
basket!({ "status": "failed", "message": r }) |
deployId!({ "status": "failed", "message": r }) |
stdout!(("failed", r))
}
_ => {
// OP_PUBLIC_DELETE_EXPIRED_PURSE_COMPLETED_BEGIN
stdout!("completed, expired purses deleted") |
basket!({ "status": "completed" })
deployId!({ "status": "completed" })
// OP_PUBLIC_DELETE_EXPIRED_PURSE_COMPLETED_END
}
}
Expand Down
6 changes: 3 additions & 3 deletions rholang/op_delete_purse.rho
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
new basket,
new deployId(`rho:rchain:deployId`),
returnCh,
stdout(`rho:io:stdout`),
deployerId(`rho:rchain:deployerId`),
Expand All @@ -14,13 +14,13 @@ in {
for (@r <- returnCh) {
match r {
String => {
basket!({ "status": "failed", "message": r }) |
deployId!({ "status": "failed", "message": r }) |
stdout!(("failed", r))
}
_ => {
// OP_DELETE_PURSE_COMPLETED_BEGIN
stdout!("completed, purse deleted") |
basket!({ "status": "completed" })
deployId!({ "status": "completed" })
// OP_DELETE_PURSE_COMPLETED_END
}
}
Expand Down
6 changes: 3 additions & 3 deletions rholang/op_deploy.rho
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
new basket,
new deployId(`rho:rchain:deployId`),
masterEntryCh,
registerContractReturnCh,
boxCh,
Expand All @@ -14,13 +14,13 @@ in {
for (@r <- registerContractReturnCh) {
match r {
String => {
basket!({ "status": "failed", "message": r }) |
deployId!({ "status": "failed", "message": r }) |
stdout!(("failed", r))
}
(true, p) => {
@(*deployerId, "rchain-token-contract", "MASTER_REGISTRY_URI", p.get("contractId"))!(p.get("superKey")) |
// OP_REGISTER_CONTRACT_COMPLETED_BEGIN
basket!({
deployId!({
"status": "completed",
"masterRegistryUri": "MASTER_REGISTRY_URI",
"contractId": p.get("contractId"),
Expand Down
6 changes: 3 additions & 3 deletions rholang/op_deploy_box.rho
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
new basket,
new deployId(`rho:rchain:deployId`),
entryCh,
registerBoxReturnCh,
stdout(`rho:io:stdout`),
Expand All @@ -14,13 +14,13 @@ in {
stdout!(r) |
match r {
String => {
basket!({ "status": "failed", "message": r }) |
deployId!({ "status": "failed", "message": r }) |
stdout!(("failed", r))
}
(true, p) => {
@(*deployerId, "rchain-token-box", "MASTER_REGISTRY_URI", p.get("boxId"))!(p.get("boxCh")) |
// OP_PUBLIC_REGISTER_BOX_COMPLETED_BEGIN
basket!({ "status": "completed", "boxId": p.get("boxId") }) |
deployId!({ "status": "completed", "boxId": p.get("boxId") }) |
stdout!("completed, box registered")
// OP_PUBLIC_REGISTER_BOX_COMPLETED_END
}
Expand Down
6 changes: 3 additions & 3 deletions rholang/op_lock.rho
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
new basket,
new deployId(`rho:rchain:deployId`),
returnCh,
stdout(`rho:io:stdout`),
deployerId(`rho:rchain:deployerId`),
Expand All @@ -13,13 +13,13 @@ in {
for (@r <- returnCh) {
match r {
String => {
basket!({ "status": "failed", "message": r }) |
deployId!({ "status": "failed", "message": r }) |
stdout!(("failed", r))
}
_ => {
// OP_LOCK_COMPLETED_BEGIN
stdout!("completed, contract locked") |
basket!({ "status": "completed" })
deployId!({ "status": "completed" })
// OP_LOCK_COMPLETED_END
}
}
Expand Down
7 changes: 3 additions & 4 deletions rholang/op_renew.rho
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@

new
basket,
deployId(`rho:rchain:deployId`),
boxCh,
returnCh,

deployerId(`rho:rchain:deployerId`),
stdout(`rho:io:stdout`)
in {
Expand All @@ -21,12 +20,12 @@ in {
for (@r <- returnCh) {
match r {
String => {
basket!({ "status": "failed", "message": r }) |
deployId!({ "status": "failed", "message": r }) |
stdout!(("failed", r))
}
(true, Nil) => {
// OP_RENEW_COMPLETED_BEGIN
basket!({ "status": "completed" }) |
deployId!({ "status": "completed" }) |
stdout!("completed, renew successful")
// OP_RENEW_COMPLETED_END
}
Expand Down
6 changes: 3 additions & 3 deletions rholang/op_swap.rho
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
new basket,
new deployId(`rho:rchain:deployId`),
returnCh,
boxCh,
stdout(`rho:io:stdout`),
Expand All @@ -12,12 +12,12 @@ in {
for (@r <- returnCh) {
match r {
String => {
basket!({ "status": "failed", "message": r }) |
deployId!({ "status": "failed", "message": r }) |
stdout!(("failed", r))
}
(true, Nil) => {
// OP_SWAP_BEGIN
basket!({ "status": "completed" }) |
deployId!({ "status": "completed" }) |
stdout!("completed, swap successful")
// OP_SWAP_END
}
Expand Down
6 changes: 3 additions & 3 deletions rholang/op_update_fee.rho
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
new basket,
new deployId(`rho:rchain:deployId`),
returnCh,
stdout(`rho:io:stdout`),
deployerId(`rho:rchain:deployerId`),
Expand All @@ -15,13 +15,13 @@ in {
stdout!(r) |
match r {
String => {
basket!({ "status": "failed", "message": r }) |
deployId!({ "status": "failed", "message": r }) |
stdout!(("failed", r))
}
_ => {
// OP_UPDATE_FEE_COMPLETED_BEGIN
stdout!("completed, fee updated") |
basket!({ "status": "completed" })
deployId!({ "status": "completed" })
// OP_UPDATE_FEE_COMPLETED_END
}
}
Expand Down
6 changes: 3 additions & 3 deletions rholang/op_update_purse_data.rho
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
new basket,
new deployId(`rho:rchain:deployId`),
returnCh,
boxCh,
stdout(`rho:io:stdout`),
Expand All @@ -11,12 +11,12 @@ in {
for (@r <- returnCh) {
match r {
String => {
basket!({ "status": "failed", "message": r }) |
deployId!({ "status": "failed", "message": r }) |
stdout!(("failed", r))
}
_ => {
// OP_UPDATE_PURSE_DATA_COMPLETED_BEGIN
basket!({ "status": "completed" }) |
deployId!({ "status": "completed" }) |
stdout!("completed, data updated")
// OP_UPDATE_PURSE_DATA_COMPLETED_END
}
Expand Down
6 changes: 3 additions & 3 deletions rholang/op_update_purse_price.rho
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
new basket,
new deployId(`rho:rchain:deployId`),
returnCh,
boxCh,
stdout(`rho:io:stdout`),
Expand All @@ -11,12 +11,12 @@ in {
for (@r <- returnCh) {
match r {
String => {
basket!({ "status": "failed", "message": r }) |
deployId!({ "status": "failed", "message": r }) |
stdout!(("failed", r))
}
_ => {
// OP_UPDATE_PURSE_PRICE_COMPLETED_BEGIN
basket!({ "status": "completed" }) |
deployId!({ "status": "completed" }) |
stdout!("completed, price updated")
// OP_UPDATE_PURSE_PRICE_COMPLETED_END
}
Expand Down
6 changes: 3 additions & 3 deletions rholang/op_withdraw.rho
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
new basket,
new deployId(`rho:rchain:deployId`),
withdrawReturnCh,
boxCh,
stdout(`rho:io:stdout`),
Expand All @@ -11,12 +11,12 @@ in {
for (@r <- withdrawReturnCh) {
match r {
String => {
basket!({ "status": "failed", "message": r }) |
deployId!({ "status": "failed", "message": r }) |
stdout!(("failed", r))
}
_ => {
// OP_WITHDRAW_COMPLETED_BEGIN
basket!({ "status": "completed" }) |
deployId!({ "status": "completed" }) |
stdout!("completed, withdraw successful")
// OP_WITHDRAW_COMPLETED_END
}
Expand Down
4 changes: 2 additions & 2 deletions src/createPursesTerm.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ module.exports.createPursesTerm = (payload) => {
.map((p, i) => '@value' + i + ' <- channel' + i)
.join('; ')}) {\n`;
rholang += ` // OP_CREATE_PURSES_COMPLETED_BEGIN\n stdout!("purses created, check results to see successes/failures") |
basket!({ "status": "completed", "results": {}${ids
deployId!({ "status": "completed", "results": {}${ids
.map((p, i) => `.union({ "${p}": value${i} })`)
.join('')}}) // OP_CREATE_PURSES_COMPLETED_END\n`;
rholang += `}\n}`;

return `new basket, entryCh, readCh, stdout(\`rho:io:stdout\`), deployerId(\`rho:rchain:deployerId\`), lookup(\`rho:registry:lookup\`) in {
return `new deployId(\`rho:rchain:deployId\`), entryCh, readCh, stdout(\`rho:io:stdout\`), deployerId(\`rho:rchain:deployerId\`), lookup(\`rho:registry:lookup\`) in {
for (superKey <<- @(*deployerId, "rchain-token-contract", "${payload.masterRegistryUri}", "${payload.contractId}")) {
${rholang}
}
Expand Down
2 changes: 1 addition & 1 deletion src/creditAndSwapTerm.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module.exports.creditAndSwapTerm = (

const term2 = term1.slice(0, indexStart) + term1.slice(indexEnd).replace(
`// OP_CREDIT_COMPLETED_END`,
`${swapTerm(payloadSwap).replace('basket,', '')}`
`${swapTerm(payloadSwap).replace('deployId(`rho:rchain:deployId`),', '')}`
);

return term2;
Expand Down
Loading

0 comments on commit 34d2759

Please sign in to comment.