Skip to content

Commit

Permalink
fixing renew name
Browse files Browse the repository at this point in the history
  • Loading branch information
bjartek committed Dec 13, 2024
1 parent f083e17 commit f34b05d
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 11 deletions.
25 changes: 20 additions & 5 deletions find_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,27 @@ func TestFIND(t *testing.T) {
// this use does not have a profile at all
user4Address := otu.O.Address("user4")

ot.Run(t, "Should get error if you try to register a name and dont have enough money", func(t *testing.T) {
otu.O.Tx("register",
ot.Run(t, "Should be able to renew lease", func(t *testing.T) {
otu.O.Tx("cleanUpInvalidatedLease",
WithSigner("user1"),
WithArg("name", "usr"),
WithArg("maxAmount", 1000.0),
).AssertFailure(t, "Balance of vault is not high enough")
WithArg("names", []string{"user1"}),
).
AssertFailure(t, "This is a valid lease. You cannot clean this up")

otu.expireLease().expireLease().tickClock(2.0)
otu.O.Tx("cleanUpInvalidatedLease",

WithSigner("user1"),
WithArg("names", []string{"user1"}),
).AssertSuccess(t)
})

ot.Run(t, "Should be able to renew nam", func(t *testing.T) {
otu.O.Tx("renewName",
WithSigner("user1"),
WithArg("name", "user1"),
WithArg("maxAmount", 10.5),
).AssertSuccess(t)
})

ot.Run(t, "Should get error if you try to register a name that is too short", func(t *testing.T) {
Expand Down
8 changes: 4 additions & 4 deletions lib/find.json
Original file line number Diff line number Diff line change
Expand Up @@ -2184,7 +2184,7 @@
"maxAmount"
]
},
"code": "import FlowToken from 0x0ae53cb6e3f42a79\nimport FungibleToken from 0xee82856bf20e2aa6\nimport FIND from 0xf3fcd2c1a78f5eee\n\ntransaction(name: String, maxAmount: UFix64) {\n\n let cost : UFix64\n let vaultRef : auth (FungibleToken.Withdraw) \u0026FlowToken.Vault? \n let finLeases : auth(FIND.LeaseOwner) \u0026FIND.LeaseCollection? \n\n prepare(acct: auth(BorrowValue) \u0026Account) {\n self.cost=FIND.calculateCostInFlow(name)\n self.vaultRef = acct.storage.borrow\u003cauth (FungibleToken.Withdraw) \u0026FlowToken.Vault\u003e(from: /storage/flowTokenVault)\n self.finLeases= acct.storage.borrow\u003cauth(FIND.LeaseOwner) \u0026FIND.LeaseCollection\u003e(from:FIND.LeaseStoragePath)\n }\n\n\n pre{\n self.vaultRef != nil : \"Could not borrow reference to the fusdVault!\"\n self.finLeases != nil : \"Could not borrow reference to find lease collection\"\n self.cost \u003c= maxAmount : \"You have not sent in enough max flow, the cost is \".concat(self.cost.toString())\n self.vaultRef!.balance \u003e self.cost : \"Balance of vault is not high enough \".concat(self.vaultRef!.balance.toString().concat(\" total balance is \").concat(self.vaultRef!.balance.toString()))\n }\n\n execute{\n let payVault \u003c- self.vaultRef!.withdraw(amount: self.cost) as! @FlowToken.Vault\n let finToken= self.finLeases!.borrow(name)\n finToken.extendLease(\u003c- payVault)\n }\n}"
"code": "import FlowToken from 0x0ae53cb6e3f42a79\nimport FungibleToken from 0xee82856bf20e2aa6\nimport FIND from 0xf3fcd2c1a78f5eee\n\ntransaction(name: String, maxAmount: UFix64) {\n\n let cost : UFix64\n let vaultRef : auth (FungibleToken.Withdraw) \u0026FlowToken.Vault? \n let finLeases : auth(FIND.LeaseOwner) \u0026FIND.LeaseCollection? \n\n prepare(acct: auth(BorrowValue) \u0026Account) {\n self.cost=FIND.calculateCostInFlow(name)\n self.vaultRef = acct.storage.borrow\u003cauth (FungibleToken.Withdraw) \u0026FlowToken.Vault\u003e(from: /storage/flowTokenVault)\n self.finLeases= acct.storage.borrow\u003cauth(FIND.LeaseOwner) \u0026FIND.LeaseCollection\u003e(from:FIND.LeaseStoragePath)\n }\n\n\n pre{\n self.vaultRef != nil : \"Could not borrow reference to the fusdVault!\"\n self.finLeases != nil : \"Could not borrow reference to find lease collection\"\n self.cost \u003c= maxAmount : \"You have not sent in enough max flow, the cost is \".concat(self.cost.toString())\n self.vaultRef!.balance \u003e self.cost : \"Balance of vault is not high enough \".concat(self.vaultRef!.balance.toString().concat(\" total balance is \").concat(self.vaultRef!.balance.toString()))\n }\n\n execute{\n let payVault \u003c- self.vaultRef!.withdraw(amount: self.cost) as! @FlowToken.Vault\n let finToken= self.finLeases!.borrowAuth(name)\n finToken.extendLease(\u003c- payVault)\n }\n}"
},
"retractOfferLeaseMarketDirectOfferSoft": {
"spec": {
Expand Down Expand Up @@ -4911,7 +4911,7 @@
"maxAmount"
]
},
"code": "import FlowToken from 0x1654653399040a61\nimport FungibleToken from 0xf233dcee88fe0abe\nimport FIND from 0x097bafa4e0b48eef\n\ntransaction(name: String, maxAmount: UFix64) {\n\n let cost : UFix64\n let vaultRef : auth (FungibleToken.Withdraw) \u0026FlowToken.Vault? \n let finLeases : auth(FIND.LeaseOwner) \u0026FIND.LeaseCollection? \n\n prepare(acct: auth(BorrowValue) \u0026Account) {\n self.cost=FIND.calculateCostInFlow(name)\n self.vaultRef = acct.storage.borrow\u003cauth (FungibleToken.Withdraw) \u0026FlowToken.Vault\u003e(from: /storage/flowTokenVault)\n self.finLeases= acct.storage.borrow\u003cauth(FIND.LeaseOwner) \u0026FIND.LeaseCollection\u003e(from:FIND.LeaseStoragePath)\n }\n\n\n pre{\n self.vaultRef != nil : \"Could not borrow reference to the fusdVault!\"\n self.finLeases != nil : \"Could not borrow reference to find lease collection\"\n self.cost \u003c= maxAmount : \"You have not sent in enough max flow, the cost is \".concat(self.cost.toString())\n self.vaultRef!.balance \u003e self.cost : \"Balance of vault is not high enough \".concat(self.vaultRef!.balance.toString().concat(\" total balance is \").concat(self.vaultRef!.balance.toString()))\n }\n\n execute{\n let payVault \u003c- self.vaultRef!.withdraw(amount: self.cost) as! @FlowToken.Vault\n let finToken= self.finLeases!.borrow(name)\n finToken.extendLease(\u003c- payVault)\n }\n}"
"code": "import FlowToken from 0x1654653399040a61\nimport FungibleToken from 0xf233dcee88fe0abe\nimport FIND from 0x097bafa4e0b48eef\n\ntransaction(name: String, maxAmount: UFix64) {\n\n let cost : UFix64\n let vaultRef : auth (FungibleToken.Withdraw) \u0026FlowToken.Vault? \n let finLeases : auth(FIND.LeaseOwner) \u0026FIND.LeaseCollection? \n\n prepare(acct: auth(BorrowValue) \u0026Account) {\n self.cost=FIND.calculateCostInFlow(name)\n self.vaultRef = acct.storage.borrow\u003cauth (FungibleToken.Withdraw) \u0026FlowToken.Vault\u003e(from: /storage/flowTokenVault)\n self.finLeases= acct.storage.borrow\u003cauth(FIND.LeaseOwner) \u0026FIND.LeaseCollection\u003e(from:FIND.LeaseStoragePath)\n }\n\n\n pre{\n self.vaultRef != nil : \"Could not borrow reference to the fusdVault!\"\n self.finLeases != nil : \"Could not borrow reference to find lease collection\"\n self.cost \u003c= maxAmount : \"You have not sent in enough max flow, the cost is \".concat(self.cost.toString())\n self.vaultRef!.balance \u003e self.cost : \"Balance of vault is not high enough \".concat(self.vaultRef!.balance.toString().concat(\" total balance is \").concat(self.vaultRef!.balance.toString()))\n }\n\n execute{\n let payVault \u003c- self.vaultRef!.withdraw(amount: self.cost) as! @FlowToken.Vault\n let finToken= self.finLeases!.borrowAuth(name)\n finToken.extendLease(\u003c- payVault)\n }\n}"
},
"renewNameDapper": {
"spec": {
Expand Down Expand Up @@ -7511,7 +7511,7 @@
"maxAmount"
]
},
"code": "import FlowToken from 0x7e60df042a9c0868\nimport FungibleToken from 0x9a0766d93b6608b7\nimport FIND from 0x35717efbbce11c74\n\ntransaction(name: String, maxAmount: UFix64) {\n\n let cost : UFix64\n let vaultRef : auth (FungibleToken.Withdraw) \u0026FlowToken.Vault? \n let finLeases : auth(FIND.LeaseOwner) \u0026FIND.LeaseCollection? \n\n prepare(acct: auth(BorrowValue) \u0026Account) {\n self.cost=FIND.calculateCostInFlow(name)\n self.vaultRef = acct.storage.borrow\u003cauth (FungibleToken.Withdraw) \u0026FlowToken.Vault\u003e(from: /storage/flowTokenVault)\n self.finLeases= acct.storage.borrow\u003cauth(FIND.LeaseOwner) \u0026FIND.LeaseCollection\u003e(from:FIND.LeaseStoragePath)\n }\n\n\n pre{\n self.vaultRef != nil : \"Could not borrow reference to the fusdVault!\"\n self.finLeases != nil : \"Could not borrow reference to find lease collection\"\n self.cost \u003c= maxAmount : \"You have not sent in enough max flow, the cost is \".concat(self.cost.toString())\n self.vaultRef!.balance \u003e self.cost : \"Balance of vault is not high enough \".concat(self.vaultRef!.balance.toString().concat(\" total balance is \").concat(self.vaultRef!.balance.toString()))\n }\n\n execute{\n let payVault \u003c- self.vaultRef!.withdraw(amount: self.cost) as! @FlowToken.Vault\n let finToken= self.finLeases!.borrow(name)\n finToken.extendLease(\u003c- payVault)\n }\n}"
"code": "import FlowToken from 0x7e60df042a9c0868\nimport FungibleToken from 0x9a0766d93b6608b7\nimport FIND from 0x35717efbbce11c74\n\ntransaction(name: String, maxAmount: UFix64) {\n\n let cost : UFix64\n let vaultRef : auth (FungibleToken.Withdraw) \u0026FlowToken.Vault? \n let finLeases : auth(FIND.LeaseOwner) \u0026FIND.LeaseCollection? \n\n prepare(acct: auth(BorrowValue) \u0026Account) {\n self.cost=FIND.calculateCostInFlow(name)\n self.vaultRef = acct.storage.borrow\u003cauth (FungibleToken.Withdraw) \u0026FlowToken.Vault\u003e(from: /storage/flowTokenVault)\n self.finLeases= acct.storage.borrow\u003cauth(FIND.LeaseOwner) \u0026FIND.LeaseCollection\u003e(from:FIND.LeaseStoragePath)\n }\n\n\n pre{\n self.vaultRef != nil : \"Could not borrow reference to the fusdVault!\"\n self.finLeases != nil : \"Could not borrow reference to find lease collection\"\n self.cost \u003c= maxAmount : \"You have not sent in enough max flow, the cost is \".concat(self.cost.toString())\n self.vaultRef!.balance \u003e self.cost : \"Balance of vault is not high enough \".concat(self.vaultRef!.balance.toString().concat(\" total balance is \").concat(self.vaultRef!.balance.toString()))\n }\n\n execute{\n let payVault \u003c- self.vaultRef!.withdraw(amount: self.cost) as! @FlowToken.Vault\n let finToken= self.finLeases!.borrowAuth(name)\n finToken.extendLease(\u003c- payVault)\n }\n}"
},
"retractOfferLeaseMarketDirectOfferSoft": {
"spec": {
Expand Down Expand Up @@ -10292,7 +10292,7 @@
"maxAmount"
]
},
"code": "import FlowToken from 0x7e60df042a9c0868\nimport FungibleToken from 0x9a0766d93b6608b7\nimport FIND from 0x35717efbbce11c74\n\ntransaction(name: String, maxAmount: UFix64) {\n\n let cost : UFix64\n let vaultRef : auth (FungibleToken.Withdraw) \u0026FlowToken.Vault? \n let finLeases : auth(FIND.LeaseOwner) \u0026FIND.LeaseCollection? \n\n prepare(acct: auth(BorrowValue) \u0026Account) {\n self.cost=FIND.calculateCostInFlow(name)\n self.vaultRef = acct.storage.borrow\u003cauth (FungibleToken.Withdraw) \u0026FlowToken.Vault\u003e(from: /storage/flowTokenVault)\n self.finLeases= acct.storage.borrow\u003cauth(FIND.LeaseOwner) \u0026FIND.LeaseCollection\u003e(from:FIND.LeaseStoragePath)\n }\n\n\n pre{\n self.vaultRef != nil : \"Could not borrow reference to the fusdVault!\"\n self.finLeases != nil : \"Could not borrow reference to find lease collection\"\n self.cost \u003c= maxAmount : \"You have not sent in enough max flow, the cost is \".concat(self.cost.toString())\n self.vaultRef!.balance \u003e self.cost : \"Balance of vault is not high enough \".concat(self.vaultRef!.balance.toString().concat(\" total balance is \").concat(self.vaultRef!.balance.toString()))\n }\n\n execute{\n let payVault \u003c- self.vaultRef!.withdraw(amount: self.cost) as! @FlowToken.Vault\n let finToken= self.finLeases!.borrow(name)\n finToken.extendLease(\u003c- payVault)\n }\n}"
"code": "import FlowToken from 0x7e60df042a9c0868\nimport FungibleToken from 0x9a0766d93b6608b7\nimport FIND from 0x35717efbbce11c74\n\ntransaction(name: String, maxAmount: UFix64) {\n\n let cost : UFix64\n let vaultRef : auth (FungibleToken.Withdraw) \u0026FlowToken.Vault? \n let finLeases : auth(FIND.LeaseOwner) \u0026FIND.LeaseCollection? \n\n prepare(acct: auth(BorrowValue) \u0026Account) {\n self.cost=FIND.calculateCostInFlow(name)\n self.vaultRef = acct.storage.borrow\u003cauth (FungibleToken.Withdraw) \u0026FlowToken.Vault\u003e(from: /storage/flowTokenVault)\n self.finLeases= acct.storage.borrow\u003cauth(FIND.LeaseOwner) \u0026FIND.LeaseCollection\u003e(from:FIND.LeaseStoragePath)\n }\n\n\n pre{\n self.vaultRef != nil : \"Could not borrow reference to the fusdVault!\"\n self.finLeases != nil : \"Could not borrow reference to find lease collection\"\n self.cost \u003c= maxAmount : \"You have not sent in enough max flow, the cost is \".concat(self.cost.toString())\n self.vaultRef!.balance \u003e self.cost : \"Balance of vault is not high enough \".concat(self.vaultRef!.balance.toString().concat(\" total balance is \").concat(self.vaultRef!.balance.toString()))\n }\n\n execute{\n let payVault \u003c- self.vaultRef!.withdraw(amount: self.cost) as! @FlowToken.Vault\n let finToken= self.finLeases!.borrowAuth(name)\n finToken.extendLease(\u003c- payVault)\n }\n}"
},
"renewNameDapper": {
"spec": {
Expand Down
2 changes: 1 addition & 1 deletion lib/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@findonflow/find-flow-contracts-1.0",
"version": "1.2.2",
"version": "1.2.3",
"description": "Cadence transactions and scripts to work with https://find.xyz for cadence 1.0",
"main": "index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion transactions/renewName.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ transaction(name: String, maxAmount: UFix64) {

execute{
let payVault <- self.vaultRef!.withdraw(amount: self.cost) as! @FlowToken.Vault
let finToken= self.finLeases!.borrow(name)
let finToken= self.finLeases!.borrowAuth(name)
finToken.extendLease(<- payVault)
}
}

0 comments on commit f34b05d

Please sign in to comment.