Skip to content

Commit

Permalink
align arg call like the other contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
zamrokk committed Aug 9, 2023
1 parent 5a0ced6 commit 58083a1
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 37 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Also update the initial storage on file `nft.storageList.jsligo` to add `offers`
Finally, compile the contract

```bash
TAQ_LIGO_IMAGE=ligolang/ligo:0.71.0 taq compile nft.jsligo
TAQ_LIGO_IMAGE=ligolang/ligo:0.71.1 taq compile nft.jsligo
```

## :credit_card: Sell at an offer price
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
// This file implement the TZIP-12 protocol (a.k.a FA2) for NFT on Tezos
// copyright Wulfman Corporation 2021

// Errors
#import "../common/errors.mligo" "Errors"
export type token_id = nat;

export type owner = address;

namespace Operators {
type owner = address;
type operator = address;
export type t = big_map<[owner, operator], set<token_id>>;
// if transfer policy is Owner_or_operator_transfer
Expand Down Expand Up @@ -117,7 +114,6 @@ namespace Operators {
};

namespace Ledger {
type owner = address;
export type t = big_map<token_id, owner>;
export const is_owner_of = (ledger: t, token_id: token_id, owner: address)
: bool => {
Expand Down Expand Up @@ -227,7 +223,7 @@ type transfer_from = {

export type transfer = list<transfer_from>;

const transfer = (t: transfer, s: storage): [list<operation>, storage] => {
const transfer = ([t,s] : [transfer,storage]): [list<operation>, storage] => {
// This function process the "txs" list. Since all transfer share the same "from_" address, we use a se

const process_atomic_transfer = (from_: address)
Expand Down Expand Up @@ -281,7 +277,7 @@ export type balance_of =

// Balance_of entrypoint

const balance_of = (b: balance_of, s: storage): [list<operation>, storage] => {
const balance_of = ([b,s]: [balance_of,storage]): [list<operation>, storage] => {
const { requests, callback } = b;
const get_balance_info = (request: request): callback => {
const { owner, token_id } = request;
Expand Down Expand Up @@ -310,7 +306,7 @@ export type unit_update =

export type update_operators = list<unit_update>;

const update_ops = (updates: update_operators, s: storage)
const update_ops = ([updates,s]: [update_operators, storage])
: [list<operation>, storage] => {
const update_operator = ([operators, update]: [Operators.t, unit_update])
: Operators.t =>
Expand Down Expand Up @@ -355,9 +351,9 @@ const main = (p: parameter, s: storage): [list<operation>, storage] => {
return match(
p,
{
Transfer: (p: transfer) => transfer(p, s),
Balance_of: (p: balance_of) => balance_of(p, s),
Update_operators: (p: update_operators) => update_ops(p, s)
Transfer: (p: transfer) => transfer([p, s]),
Balance_of: (p: balance_of) => balance_of([p, s]),
Update_operators: (p: update_operators) => update_ops([p, s])
}
)
};
Expand Down
54 changes: 30 additions & 24 deletions solution/contracts/nft.jsligo
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,16 @@ type ret = [list<operation>, storage];
const transfer = (p: NFT.transfer, s: storage): ret => {
const ret2: [list<operation>, NFT.storage] =
NFT.transfer(
p,
{
ledger: s.ledger,
metadata: s.metadata,
token_metadata: s.token_metadata,
operators: s.operators,
token_ids: s.token_ids
}
[
p,
{
ledger: s.ledger,
metadata: s.metadata,
token_metadata: s.token_metadata,
operators: s.operators,
token_ids: s.token_ids
}
]
);
return [
ret2[0],
Expand All @@ -58,14 +60,16 @@ const transfer = (p: NFT.transfer, s: storage): ret => {
const balance_of = (p: NFT.balance_of, s: storage): ret => {
const ret2: [list<operation>, NFT.storage] =
NFT.balance_of(
p,
{
ledger: s.ledger,
metadata: s.metadata,
token_metadata: s.token_metadata,
operators: s.operators,
token_ids: s.token_ids
}
[
p,
{
ledger: s.ledger,
metadata: s.metadata,
token_metadata: s.token_metadata,
operators: s.operators,
token_ids: s.token_ids
}
]
);
return [
ret2[0],
Expand All @@ -84,14 +88,16 @@ const balance_of = (p: NFT.balance_of, s: storage): ret => {
const update_operators = (p: NFT.update_operators, s: storage): ret => {
const ret2: [list<operation>, NFT.storage] =
NFT.update_ops(
p,
{
ledger: s.ledger,
metadata: s.metadata,
token_metadata: s.token_metadata,
operators: s.operators,
token_ids: s.token_ids
}
[
p,
{
ledger: s.ledger,
metadata: s.metadata,
token_metadata: s.token_metadata,
operators: s.operators,
token_ids: s.token_ids
}
]
);
return [
ret2[0],
Expand Down

0 comments on commit 58083a1

Please sign in to comment.