Skip to content

Commit

Permalink
fix for ligo/fa v1.0.9
Browse files Browse the repository at this point in the history
  • Loading branch information
zamrokk committed Oct 31, 2023
1 parent 9820089 commit fd3ea7e
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 21 deletions.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ export type storage = {
administrators: set<address>,
offers: map<[address, nat], offer>, //user sells an offer for a token_id
ledger: FA2Impl.Datatypes.ledger,
ledger: FA2Impl.MultiAsset.ledger,
metadata: FA2Impl.TZIP16.metadata,
token_metadata: FA2Impl.TZIP12.tokenMetadata,
operators: FA2Impl.Datatypes.operators,
operators: FA2Impl.MultiAsset.operators,
};
```

Expand Down Expand Up @@ -99,13 +99,13 @@ const mint = (
[Tezos.get_sender(), token_id],
quantity as nat,
s.ledger
) as FA2Impl.Datatypes.ledger,
) as FA2Impl.MultiAsset.ledger,
token_metadata: Big_map.add(
token_id,
{ token_id: token_id, token_info: token_info },
s.token_metadata
),
operators: Big_map.empty as FA2Impl.Datatypes.operators
operators: Big_map.empty as FA2Impl.MultiAsset.operators
}
]
};
Expand All @@ -119,12 +119,12 @@ const sell = ([token_id, quantity, price]: [nat, nat, nat], s: storage): ret =>
//check balance of seller
const sellerBalance =
FA2Impl.Sidecar.get_for_user([s.ledger, Tezos.get_source(), token_id]);
FA2Impl.MultiAsset.get_for_user([s.ledger, Tezos.get_source(), token_id]);
if (quantity > sellerBalance) return failwith("2");
//need to allow the contract itself to be an operator on behalf of the seller
const newOperators =
FA2Impl.Sidecar.add_operator(
FA2Impl.MultiAsset.add_operator(
[s.operators, Tezos.get_source(), Tezos.get_self_address(), token_id]
);
//DECISION CHOICE: if offer already exists, we just override it
Expand Down Expand Up @@ -172,11 +172,11 @@ const buy = ([token_id, quantity, seller]: [nat, nat, address], s: storage): ret
//transfer tokens from seller to buyer
let ledger =
FA2Impl.Sidecar.decrease_token_amount_for_user(
FA2Impl.MultiAsset.decrease_token_amount_for_user(
[s.ledger, seller, token_id, quantity]
);
ledger
= FA2Impl.Sidecar.increase_token_amount_for_user(
= FA2Impl.MultiAsset.increase_token_amount_for_user(
[ledger, Tezos.get_source(), token_id, quantity]
);
//update new offer
Expand Down Expand Up @@ -239,7 +239,7 @@ const default_storage: Contract.storage = {
Compile again and deploy to ghostnet

```bash
TAQ_LIGO_IMAGE=ligolang/ligo:1.0.0 taq compile nft.jsligo
TAQ_LIGO_IMAGE=ligolang/ligo:1.1.0 taq compile nft.jsligo
taq deploy nft.tz -e "testing"
```

Expand Down
2 changes: 1 addition & 1 deletion solution/_ligo/ligo/installation.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"app@link-dev:./ligo.json":"/project","@ligo/[email protected].8@ffffffff":"./.ligo/source/i/ligo__s__fa__1.0.8__ffffffff"}
{"app@link-dev:./ligo.json":"/project","@ligo/[email protected].9@ffffffff":"./.ligo/source/i/ligo__s__fa__1.0.9__ffffffff"}
10 changes: 9 additions & 1 deletion solution/artifacts/nft.tz
Original file line number Diff line number Diff line change
Expand Up @@ -304,10 +304,18 @@
SOME ;
PUSH string "symbol" ;
UPDATE ;
DIG 6 ;
DUP 7 ;
SOME ;
PUSH string "thumbnailUri" ;
UPDATE ;
DUP 7 ;
SOME ;
PUSH string "displayUri" ;
UPDATE ;
DIG 6 ;
SOME ;
PUSH string "artifactUri" ;
UPDATE ;
PUSH bytes 0x5b22545a49502d3132225d ;
SOME ;
PUSH string "interfaces" ;
Expand Down
16 changes: 8 additions & 8 deletions solution/contracts/nft.jsligo
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ export type storage = {
administrators: set<address>,
offers: map<[address, nat], offer>, //user sells an offer for a token_id

ledger: FA2Impl.Datatypes.ledger,
ledger: FA2Impl.MultiAsset.ledger,
metadata: FA2Impl.TZIP16.metadata,
token_metadata: FA2Impl.TZIP12.tokenMetadata,
operators: FA2Impl.Datatypes.operators,
operators: FA2Impl.MultiAsset.operators,
};

type ret = [list<operation>, storage];
Expand Down Expand Up @@ -135,13 +135,13 @@ const mint = (
[Tezos.get_sender(), token_id],
quantity as nat,
s.ledger
) as FA2Impl.Datatypes.ledger,
) as FA2Impl.MultiAsset.ledger,
token_metadata: Big_map.add(
token_id,
{ token_id: token_id, token_info: token_info },
s.token_metadata
),
operators: Big_map.empty as FA2Impl.Datatypes.operators
operators: Big_map.empty as FA2Impl.MultiAsset.operators
}
]
};
Expand All @@ -151,12 +151,12 @@ const sell = ([token_id, quantity, price]: [nat, nat, nat], s: storage): ret =>
//check balance of seller

const sellerBalance =
FA2Impl.Sidecar.get_for_user([s.ledger, Tezos.get_source(), token_id]);
FA2Impl.MultiAsset.get_for_user([s.ledger, Tezos.get_source(), token_id]);
if (quantity > sellerBalance) return failwith("2");
//need to allow the contract itself to be an operator on behalf of the seller

const newOperators =
FA2Impl.Sidecar.add_operator(
FA2Impl.MultiAsset.add_operator(
[s.operators, Tezos.get_source(), Tezos.get_self_address(), token_id]
);
//DECISION CHOICE: if offer already exists, we just override it
Expand Down Expand Up @@ -200,11 +200,11 @@ const buy = ([token_id, quantity, seller]: [nat, nat, address], s: storage): ret
//transfer tokens from seller to buyer

let ledger =
FA2Impl.Sidecar.decrease_token_amount_for_user(
FA2Impl.MultiAsset.decrease_token_amount_for_user(
[s.ledger, seller, token_id, quantity]
);
ledger
= FA2Impl.Sidecar.increase_token_amount_for_user(
= FA2Impl.MultiAsset.increase_token_amount_for_user(
[ledger, Tezos.get_source(), token_id, quantity]
);
//update new offer
Expand Down
2 changes: 1 addition & 1 deletion solution/ligo.esy.lock/index.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"checksum":"9d098de4b5645c2c68a131b5b91bce33fbfdcae0","root":"app@link-dev:./ligo.json","node":{"@ligo/[email protected].8@ffffffff":{"id":"@ligo/[email protected].8@ffffffff","name":"@ligo/fa","version":"1.0.8","source":{"type":"library","source":["archive:https://packages.ligolang.org/-/api/@ligo/fa/-/@ligo/fa-1.0.8.tgz#sha1:accc6752ec8adc3e89b4386ea778b7e670c49c1f"]},"overrides":[],"dependencies":[],"devDependencies":[]},"app@link-dev:./ligo.json":{"id":"app@link-dev:./ligo.json","name":"app","version":"link-dev:./ligo.json","source":{"type":"link-dev","path":".","manifest":"ligo.json"},"overrides":[],"dependencies":["@ligo/[email protected].8@ffffffff"],"devDependencies":[]}}}
{"checksum":"00be8a6609fa863725d45bfc41030b3edd91a79d","root":"app@link-dev:./ligo.json","node":{"@ligo/[email protected].9@ffffffff":{"id":"@ligo/[email protected].9@ffffffff","name":"@ligo/fa","version":"1.0.9","source":{"type":"library","source":["archive:https://packages.ligolang.org/-/api/@ligo/fa/-/@ligo/fa-1.0.9.tgz#sha1:09725dc774f0418c3ad9b9ee7d293296f96b093e"]},"overrides":[],"dependencies":[],"devDependencies":[]},"app@link-dev:./ligo.json":{"id":"app@link-dev:./ligo.json","name":"app","version":"link-dev:./ligo.json","source":{"type":"link-dev","path":".","manifest":"ligo.json"},"overrides":[],"dependencies":["@ligo/[email protected].9@ffffffff"],"devDependencies":[]}}}
2 changes: 1 addition & 1 deletion solution/ligo.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{ "name": "app", "dependencies": { "@ligo/fa": "^1.0.8" } }
{ "dependencies": { "@ligo/fa": "^1.0.9" }, "name": "app" }

0 comments on commit fd3ea7e

Please sign in to comment.