-
Notifications
You must be signed in to change notification settings - Fork 167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DEVX-291c #1425
base: master
Are you sure you want to change the base?
DEVX-291c #1425
Changes from all commits
908f897
2c72336
4595ad2
d18f511
744f6d3
fb81aeb
3cae381
85d0f16
ab989c0
6a40478
19bed1d
9881d01
08ad81e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/build | ||
/scribble.log | ||
/convert.log | ||
/dev.log | ||
/gen.log | ||
/md | ||
/secret.env |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import { Reach, test } from '@reach-sh/stdlib'; | ||
const stdlib = new Reach(process.env, { REACH_NO_WARN: 'Y' }); | ||
|
||
const startingBalance = stdlib.parseCurrency(100); | ||
const [minter, receiver] = await stdlib.newTestAccounts(2, startingBalance); | ||
minter.setDebugLabel('Minter'); | ||
receiver.setDebugLabel('Receiver'); | ||
|
||
const gasLimit = 5000000; | ||
if (stdlib.connector != 'ALGO') { | ||
minter.setGasLimit(gasLimit) && receiver.setGasLimit(gasLimit) | ||
}; | ||
|
||
const mintAddr = minter.getAddress(); | ||
console.log(`Minter's address is ${mintAddr}`); | ||
const recAddr = receiver.getAddress(); | ||
console.log(`Receiver's address is ${recAddr}`); | ||
|
||
const minterAddrFormat = await stdlib.formatAddress(minter); | ||
console.log(`The minter's formatted address is ${minterAddrFormat}`); | ||
const receiverAddrFormat = await stdlib.formatAddress(receiver); | ||
console.log(`The receiver's formatted address is ${receiverAddrFormat}`); | ||
|
||
const fmt = (x) => stdlib.formatCurrency(x, 4); | ||
const getBal = async (who, tok) => tok ? (await stdlib.balanceOf(who, tok)) : fmt(await stdlib.balanceOf(who)); | ||
|
||
const logBalance = async (acc, tok) => { | ||
const bal = await getBal(acc, tok); | ||
const unit = tok ? 'of the NFT' : stdlib.standardUnit; | ||
console.log(`${acc.getDebugLabel()} has ${bal} ${unit}.`); | ||
return bal; | ||
} | ||
|
||
await logBalance(minter); | ||
|
||
const name = (stdlib.connector == 'ALGO') ? "JPAlgos" : "JPals"; | ||
const symbol = (stdlib.connector == 'ALGO') ? "JPA" : "JPAL"; | ||
TheChronicMonster marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
const opts = { | ||
supply: 1, | ||
url: "ipfs://bafybeigdyrzt5...", //asset url | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it is more compelling if you demonstrate actually creating it too. The same information that you're going to put in the Note field, you want to upload to IPFS. This page has a little tutorial: under "Adding data to IPFS" If you are nervous about including it in the code always or having our CI do it, etc, then at least make a little program on the side (or a way to run this program) and comment on it in your guide |
||
c: null, // clawback | ||
f: null, // freeze address | ||
defaultFrozen: false, | ||
reserve: null, | ||
note: Uint8Array[1], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is just There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that you should use the ARC spec and have the note actually contain what it is supposed to |
||
}; | ||
|
||
const mintNFT = async (minter, name, symbol, opts) => { | ||
console.log(`Creating the NFT`); | ||
const theNFT = await stdlib.launchToken(minter, name, symbol, opts); | ||
console.log(theNFT); | ||
return theNFT.id; | ||
} | ||
|
||
const transferNFT = async (minter, receiver, nftId, supply) => { | ||
const preAmtNFT = await logBalance(minter, nftId); | ||
|
||
if (stdlib.connector == 'ALGO') { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you should always do it and note that it does nothing on ETH |
||
await receiver.tokenAccept(nftId); | ||
console.log(`${receiver.getDebugLabel()} opted-in to NFT`); | ||
}; | ||
await stdlib.transfer(minter, receiver, supply, nftId); | ||
console.log(`${supply} ${symbol} transferred from ${minter.getDebugLabel()} to ${receiver.getDebugLabel()}`); | ||
|
||
const postAmtNFT = await logBalance(receiver, nftId); | ||
test.chk('NFT AMT', preAmtNFT, postAmtNFT); | ||
} | ||
|
||
const nftId = await mintNFT(minter, name, symbol, opts); | ||
await transferNFT(minter, receiver, nftId, opts.supply); | ||
await logBalance(minter); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
'reach 0.1' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Verifying knowledge assertions | ||
Verifying for generic connector | ||
Verifying when ALL participants are honest | ||
Verifying when NO participants are honest | ||
Checked 0 theorems; No failures! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In these two functions, you have an "acceptable" path on
tok
beingundefined
. I think it is kinder to use(who, tok = false)
, to better communicate to the reader that often you expect it to not be provided