Skip to content

Commit

Permalink
cadence 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
avcdsld committed Oct 30, 2024
1 parent b651a35 commit e869059
Show file tree
Hide file tree
Showing 4 changed files with 1,397 additions and 162 deletions.
2 changes: 1 addition & 1 deletion packages/react-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"@martianwallet/aptos-wallet-adapter": "^0.0.4",
"@mysten/sui.js": "^0.37.1",
"@nightlylabs/aptos-wallet-adapter-plugin": "^0.2.12",
"@onflow/fcl": "^1.4.1",
"@onflow/fcl": "^1.12.3",
"@pontem/wallet-adapter-plugin": "^0.2.0",
"@rise-wallet/wallet-adapter": "^0.1.2",
"@suiet/wallet-kit": "^0.2.15",
Expand Down
15 changes: 7 additions & 8 deletions packages/react-app/src/components/templates/HomeTemplate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,8 @@ export const HomeTemplate: React.FC = () => {
network="testnet"
isReplica={false}
max={max}
explorerUrlPrefix="https://testnet.flowscan.org/transaction/"
externalUrl="https://testnet.flowscan.org/contract/A.0ba61bc9eb0b44c8.SakutaroPoem/overview"
explorerUrlPrefix="https://testnet.flowdiver.io/tx/"
externalUrl="https://testnet.flowdiver.io/contract/A.0ba61bc9eb0b44c8.SakutaroPoem?tab=deployments"
/>
<MintButtonFlow
Expand All @@ -340,26 +340,25 @@ export const HomeTemplate: React.FC = () => {
isReplica={true}
max={10000}
explorerUrlPrefix="https://testnet.flowscan.org/transaction/"
externalUrl="https://testnet.flowscan.org/contract/A.0ba61bc9eb0b44c8.SakutaroPoemReplica/overview"
externalUrl="https://testnet.flowdiver.io/contract/A.0ba61bc9eb0b44c8.SakutaroPoemReplica?tab=deployments"
/> */}

<MintButtonFlow
label="Flow"
network="mainnet"
isReplica={false}
max={max}
explorerUrlPrefix="https://flowscan.org/transaction/"
otherMarketUrl="https://matrixmarket.xyz/collection/mainnet_flow-A.e46c2c24053641e2.SakutaroPoem"
externalUrl="https://flowscan.org/contract/A.e46c2c24053641e2.SakutaroPoem/overview"
explorerUrlPrefix="https://www.flowdiver.io/tx/"
externalUrl="https://www.flowdiver.io/contract/A.e46c2c24053641e2.SakutaroPoem?tab=deployments"
/>

{/* <MintButtonFlow
label="Flow(Replica version)"
network="mainnet"
isReplica={true}
max={10000}
explorerUrlPrefix="https://flowscan.org/transaction/"
externalUrl="https://flowscan.org/contract/A.e46c2c24053641e2.SakutaroPoemReplica/overview"
explorerUrlPrefix="https://www.flowdiver.io/tx/"
externalUrl="https://www.flowdiver.io/contract/A.e46c2c24053641e2.SakutaroPoemReplica?tab=deployments"
/> */}

{/* <MintButtonTezos
Expand Down
96 changes: 47 additions & 49 deletions packages/react-app/src/components/templates/MintButtonFlow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,14 @@ import NonFungibleToken from ${nonFungibleTokenAddress}
import SakutaroPoem from ${sakutaroPoemAddress}
transaction() {
prepare(signer: AuthAccount) {
if signer.borrow<&SakutaroPoem.Collection>(from: SakutaroPoem.CollectionStoragePath) == nil {
signer.save(<- SakutaroPoem.createEmptyCollection(), to: SakutaroPoem.CollectionStoragePath)
signer.link<&{NonFungibleToken.CollectionPublic, SakutaroPoem.SakutaroPoemCollectionPublic}>(
SakutaroPoem.CollectionPublicPath,
target: SakutaroPoem.CollectionStoragePath
)
prepare(signer: auth(BorrowValue, SaveValue, IssueStorageCapabilityController, PublishCapability) &Account) {
if signer.storage.borrow<&SakutaroPoem.Collection>(from: SakutaroPoem.CollectionStoragePath) == nil {
signer.storage.save(<- SakutaroPoem.createEmptyCollection(nftType: Type<@SakutaroPoem.NFT>()), to: SakutaroPoem.CollectionStoragePath)
let cap = signer.capabilities.storage.issue<&SakutaroPoem.Collection>(SakutaroPoem.CollectionStoragePath)
signer.capabilities.publish(cap, at: SakutaroPoem.CollectionPublicPath)
}
let nft <- SakutaroPoem.mintNFT()
let collectionRef = signer.borrow<&SakutaroPoem.Collection>(from: SakutaroPoem.CollectionStoragePath) ?? panic("Not Found")
let collectionRef = signer.storage.borrow<&SakutaroPoem.Collection>(from: SakutaroPoem.CollectionStoragePath) ?? panic("Not Found")
if collectionRef.getIDs().length > 0 {
panic("Only one can be minted")
}
Expand All @@ -78,16 +76,14 @@ import NonFungibleToken from ${nonFungibleTokenAddress}
import SakutaroPoemReplica from ${sakutaroPoemAddress}
transaction() {
prepare(signer: AuthAccount) {
if signer.borrow<&SakutaroPoemReplica.Collection>(from: SakutaroPoemReplica.CollectionStoragePath) == nil {
signer.save(<- SakutaroPoemReplica.createEmptyCollection(), to: SakutaroPoemReplica.CollectionStoragePath)
signer.link<&{NonFungibleToken.CollectionPublic, SakutaroPoemReplica.SakutaroPoemReplicaCollectionPublic}>(
SakutaroPoemReplica.CollectionPublicPath,
target: SakutaroPoemReplica.CollectionStoragePath
)
prepare(signer: auth(BorrowValue, SaveValue, IssueStorageCapabilityController, PublishCapability) &Account) {
if signer.storage.borrow<&SakutaroPoemReplica.Collection>(from: SakutaroPoemReplica.CollectionStoragePath) == nil {
signer.storage.save(<- SakutaroPoemReplica.createEmptyCollection(nftType: Type<@SakutaroPoemReplica.NFT>()), to: SakutaroPoemReplica.CollectionStoragePath)
let cap = signer.capabilities.storage.issue<&SakutaroPoemReplica.Collection>(SakutaroPoemReplica.CollectionStoragePath)
signer.capabilities.publish(cap, at: SakutaroPoemReplica.CollectionPublicPath)
}
let nft <- SakutaroPoemReplica.mintNFT()
let collectionRef = signer.borrow<&SakutaroPoemReplica.Collection>(from: SakutaroPoemReplica.CollectionStoragePath) ?? panic("Not Found")
let collectionRef = signer.storage.borrow<&SakutaroPoemReplica.Collection>(from: SakutaroPoemReplica.CollectionStoragePath) ?? panic("Not Found")
if collectionRef.getIDs().length > 0 {
panic("Only one can be minted")
}
Expand Down Expand Up @@ -130,45 +126,47 @@ transaction() {
import NonFungibleToken from ${nonFungibleTokenAddress}
import SakutaroPoem from ${sakutaroPoemAddress}
pub fun main(): String {
let collectionRef = getAccount(${account!["addr"]})
.getCapability(SakutaroPoem.CollectionPublicPath)
.borrow<&{SakutaroPoem.SakutaroPoemCollectionPublic}>()
if collectionRef == nil {
return ""
}
let ids = collectionRef!.getIDs()
if ids.length == 0 {
return ""
}
access(all) fun main(): String {
let collection = getAccount(${account!["addr"]})
.capabilities.get<&SakutaroPoem.Collection>(SakutaroPoem.CollectionPublicPath)
.borrow()
if collection == nil {
return ""
}
let ids = collection!.getIDs()
if ids.length == 0 {
return ""
}
let nft = collectionRef!.borrowPoem(id: ids[0])!
let metadata = nft.resolveView(Type<SakutaroPoem.SakutaroPoemMetadataView>())!
let poem = metadata as! SakutaroPoem.SakutaroPoemMetadataView
let nft = collection!.borrowPoem(ids[0])!
let metadata = nft.resolveView(Type<SakutaroPoem.SakutaroPoemMetadataView>())!
let poem = metadata as! SakutaroPoem.SakutaroPoemMetadataView
return poem.svgBase64 ?? ""
return poem.svgBase64 ?? ""
}`
: `\
import NonFungibleToken from ${nonFungibleTokenAddress}
import SakutaroPoem from ${sakutaroPoemAddress}
import SakutaroPoemReplica from ${sakutaroPoemAddress}
access(all) fun main(): String {
let collection = getAccount(${account!["addr"]})
.capabilities.get<&SakutaroPoemReplica.Collection>(SakutaroPoemReplica.CollectionPublicPath)
.borrow()
if collection == nil {
return ""
}
pub fun main(): String {
let collectionRef = getAccount(${account!["addr"]})
.getCapability(SakutaroPoem.CollectionPublicPath)
.borrow<&{SakutaroPoem.SakutaroPoemCollectionPublic}>()
if collectionRef == nil {
return ""
}
let ids = collectionRef!.getIDs()
if ids.length == 0 {
return ""
}
let ids = collection!.getIDs()
if ids.length == 0 {
return ""
}
let nft = collectionRef!.borrowPoem(id: ids[0])!
let metadata = nft.resolveView(Type<SakutaroPoem.SakutaroPoemMetadataView>())!
let poem = metadata as! SakutaroPoem.SakutaroPoemMetadataView
let nft = collection!.borrowPoem(ids[0])!
let metadata = nft.resolveView(Type<SakutaroPoemReplica.SakutaroPoemMetadataView>())!
let poem = metadata as! SakutaroPoemReplica.SakutaroPoemMetadataView
return poem.svgBase64 ?? ""
return poem.svgBase64 ?? ""
}`,
});
console.log(svgAsBase64);
Expand All @@ -193,13 +191,13 @@ pub fun main(): String {
? `\
import SakutaroPoem from ${sakutaroPoemAddress}
pub fun main(): UInt64 {
access(all) fun main(): UInt64 {
return SakutaroPoem.totalSupply
}`
: `\
import SakutaroPoemReplica from ${sakutaroPoemAddress}
pub fun main(): UInt64 {
access(all) fun main(): UInt64 {
return SakutaroPoemReplica.totalSupply
}`,
})
Expand Down
Loading

0 comments on commit e869059

Please sign in to comment.