├── .editorconfig ├── .env.dist ├── .github ├── config.yaml └── workflows │ ├── sui-publish.yml │ ├── sui-test.yml │ ├── update-registry-main.yml │ └── update-registry-test.yml ├── .gitignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── assets ├── 3_layer.png ├── display.png └── logo.svg ├── bin ├── build.sh ├── clean.sh ├── gen_client.sh ├── mappings.sh ├── publish.sh ├── register-all.sh ├── register.sh ├── reset_tomls.py ├── test.sh └── update_docs.py ├── client ├── .eslintrc.json ├── _dependencies │ └── source │ │ ├── 0x1 │ │ ├── ascii │ │ │ └── structs.ts │ │ ├── bit-vector │ │ │ └── structs.ts │ │ ├── fixed-point32 │ │ │ └── structs.ts │ │ ├── index.ts │ │ ├── init.ts │ │ ├── option │ │ │ └── structs.ts │ │ ├── string │ │ │ └── structs.ts │ │ └── type-name │ │ │ └── structs.ts │ │ └── 0x2 │ │ ├── authenticator-state │ │ └── structs.ts │ │ ├── bag │ │ └── structs.ts │ │ ├── balance │ │ └── structs.ts │ │ ├── bcs │ │ └── structs.ts │ │ ├── bls12381 │ │ └── structs.ts │ │ ├── borrow │ │ └── structs.ts │ │ ├── clock │ │ └── structs.ts │ │ ├── coin │ │ └── structs.ts │ │ ├── deny-list │ │ └── structs.ts │ │ ├── display │ │ └── structs.ts │ │ ├── dynamic-field │ │ └── structs.ts │ │ ├── dynamic-object-field │ │ └── structs.ts │ │ ├── groth16 │ │ └── structs.ts │ │ ├── group-ops │ │ └── structs.ts │ │ ├── index.ts │ │ ├── init.ts │ │ ├── kiosk-extension │ │ └── structs.ts │ │ ├── kiosk │ │ └── structs.ts │ │ ├── linked-table │ │ └── structs.ts │ │ ├── object-bag │ │ └── structs.ts │ │ ├── object-table │ │ └── structs.ts │ │ ├── object │ │ └── structs.ts │ │ ├── package │ │ └── structs.ts │ │ ├── priority-queue │ │ └── structs.ts │ │ ├── random │ │ └── structs.ts │ │ ├── sui │ │ └── structs.ts │ │ ├── table-vec │ │ └── structs.ts │ │ ├── table │ │ └── structs.ts │ │ ├── token │ │ └── structs.ts │ │ ├── transfer-policy │ │ └── structs.ts │ │ ├── transfer │ │ └── structs.ts │ │ ├── tx-context │ │ └── structs.ts │ │ ├── url │ │ └── structs.ts │ │ ├── vec-map │ │ └── structs.ts │ │ ├── vec-set │ │ └── structs.ts │ │ ├── versioned │ │ └── structs.ts │ │ ├── zklogin-verified-id │ │ └── structs.ts │ │ └── zklogin-verified-issuer │ │ └── structs.ts ├── _framework │ ├── init-source.ts │ ├── loader.ts │ ├── reified.ts │ └── util.ts ├── allowlist │ ├── allowlist │ │ ├── functions.ts │ │ └── structs.ts │ ├── frozen-pub │ │ ├── functions.ts │ │ └── structs.ts │ ├── index.ts │ ├── init.ts │ └── ob-allowlist │ │ ├── functions.ts │ │ └── structs.ts ├── authlist │ ├── authlist │ │ ├── functions.ts │ │ └── structs.ts │ ├── frozen-pub │ │ ├── functions.ts │ │ └── structs.ts │ ├── index.ts │ ├── init.ts │ └── ob-authlist │ │ ├── functions.ts │ │ └── structs.ts ├── critbit │ ├── critbit-u64 │ │ ├── functions.ts │ │ └── structs.ts │ ├── index.ts │ └── init.ts ├── gen.toml ├── kiosk │ ├── frozen-pub │ │ ├── functions.ts │ │ └── structs.ts │ ├── index.ts │ ├── init.ts │ ├── kiosk │ │ ├── functions.ts │ │ └── structs.ts │ └── ob-kiosk │ │ ├── functions.ts │ │ └── structs.ts ├── launchpad │ ├── dutch-auction │ │ ├── functions.ts │ │ └── structs.ts │ ├── english-auction │ │ ├── functions.ts │ │ └── structs.ts │ ├── fixed-price │ │ ├── functions.ts │ │ └── structs.ts │ ├── flat-fee │ │ ├── functions.ts │ │ └── structs.ts │ ├── frozen-pub │ │ ├── functions.ts │ │ └── structs.ts │ ├── index.ts │ ├── init.ts │ ├── inventory │ │ ├── functions.ts │ │ └── structs.ts │ ├── launchpad │ │ ├── functions.ts │ │ └── structs.ts │ ├── limited-fixed-price │ │ ├── functions.ts │ │ └── structs.ts │ ├── listing │ │ ├── functions.ts │ │ └── structs.ts │ ├── market-whitelist │ │ ├── functions.ts │ │ └── structs.ts │ ├── marketplace │ │ ├── functions.ts │ │ └── structs.ts │ ├── proceeds │ │ ├── functions.ts │ │ └── structs.ts │ ├── rebate │ │ ├── functions.ts │ │ └── structs.ts │ ├── venue │ │ ├── functions.ts │ │ └── structs.ts │ └── warehouse │ │ ├── functions.ts │ │ └── structs.ts ├── liquidity-layer-v-1 │ ├── bidding │ │ ├── functions.ts │ │ └── structs.ts │ ├── frozen-pub │ │ ├── functions.ts │ │ └── structs.ts │ ├── index.ts │ ├── init.ts │ ├── liquidity-layer │ │ ├── functions.ts │ │ └── structs.ts │ ├── orderbook │ │ ├── functions.ts │ │ └── structs.ts │ └── trading │ │ ├── functions.ts │ │ └── structs.ts ├── nft-protocol │ ├── access-policy │ │ ├── functions.ts │ │ └── structs.ts │ ├── attributes │ │ ├── functions.ts │ │ └── structs.ts │ ├── collection │ │ ├── functions.ts │ │ └── structs.ts │ ├── composable-nft │ │ ├── functions.ts │ │ └── structs.ts │ ├── composable-svg │ │ ├── functions.ts │ │ └── structs.ts │ ├── composable-url │ │ ├── functions.ts │ │ └── structs.ts │ ├── creators │ │ ├── functions.ts │ │ └── structs.ts │ ├── display-info │ │ ├── functions.ts │ │ └── structs.ts │ ├── frozen-pub │ │ ├── functions.ts │ │ └── structs.ts │ ├── index.ts │ ├── init.ts │ ├── mint-cap │ │ ├── functions.ts │ │ └── structs.ts │ ├── mint-event │ │ ├── functions.ts │ │ └── structs.ts │ ├── mint-pass │ │ ├── functions.ts │ │ └── structs.ts │ ├── mint-supply │ │ ├── functions.ts │ │ └── structs.ts │ ├── nft-bag │ │ ├── functions.ts │ │ └── structs.ts │ ├── nft-protocol │ │ ├── functions.ts │ │ └── structs.ts │ ├── nft │ │ ├── functions.ts │ │ └── structs.ts │ ├── p2p-list-domain │ │ ├── functions.ts │ │ └── structs.ts │ ├── p2p-list │ │ ├── functions.ts │ │ └── structs.ts │ ├── plugins │ │ ├── functions.ts │ │ └── structs.ts │ ├── royalty-strategy-bps │ │ ├── functions.ts │ │ └── structs.ts │ ├── royalty │ │ ├── functions.ts │ │ └── structs.ts │ ├── session-token │ │ ├── functions.ts │ │ └── structs.ts │ ├── supply │ │ ├── functions.ts │ │ └── structs.ts │ ├── svg │ │ ├── functions.ts │ │ └── structs.ts │ ├── symbol │ │ ├── functions.ts │ │ └── structs.ts │ ├── tags │ │ └── functions.ts │ ├── transfer-allowlist-domain │ │ ├── functions.ts │ │ └── structs.ts │ ├── transfer-allowlist │ │ ├── functions.ts │ │ └── structs.ts │ ├── transfer-token │ │ ├── functions.ts │ │ └── structs.ts │ └── url │ │ └── functions.ts ├── originmate │ ├── balances │ │ ├── functions.ts │ │ └── structs.ts │ ├── bloom-filter │ │ ├── functions.ts │ │ └── structs.ts │ ├── box │ │ ├── functions.ts │ │ └── structs.ts │ ├── crit-bit-u64 │ │ ├── functions.ts │ │ └── structs.ts │ ├── crit-bit │ │ ├── functions.ts │ │ └── structs.ts │ ├── date │ │ └── functions.ts │ ├── escrow-shared │ │ ├── functions.ts │ │ └── structs.ts │ ├── escrow │ │ ├── functions.ts │ │ └── structs.ts │ ├── i128-type │ │ ├── functions.ts │ │ └── structs.ts │ ├── i64-type │ │ ├── functions.ts │ │ └── structs.ts │ ├── index.ts │ ├── init.ts │ ├── linear-vesting │ │ ├── functions.ts │ │ └── structs.ts │ ├── math-safe-precise │ │ └── functions.ts │ ├── math-u128 │ │ └── functions.ts │ ├── math │ │ └── functions.ts │ ├── merkle-proof │ │ └── functions.ts │ ├── object-box │ │ ├── functions.ts │ │ └── structs.ts │ ├── object-vec │ │ ├── functions.ts │ │ └── structs.ts │ ├── quadratic-vesting │ │ ├── functions.ts │ │ └── structs.ts │ ├── to-string │ │ └── functions.ts │ ├── typed-id │ │ ├── functions.ts │ │ └── structs.ts │ └── vectors │ │ └── functions.ts ├── permissions │ ├── frozen-pub │ │ ├── functions.ts │ │ └── structs.ts │ ├── frozen-publisher │ │ ├── functions.ts │ │ └── structs.ts │ ├── index.ts │ ├── init.ts │ ├── permissions │ │ ├── functions.ts │ │ └── structs.ts │ ├── quorum │ │ ├── functions.ts │ │ └── structs.ts │ └── witness │ │ ├── functions.ts │ │ └── structs.ts ├── pseudorandom │ ├── index.ts │ ├── init.ts │ └── pseudorandom │ │ ├── functions.ts │ │ └── structs.ts ├── request │ ├── borrow-request │ │ ├── functions.ts │ │ └── structs.ts │ ├── frozen-pub │ │ ├── functions.ts │ │ └── structs.ts │ ├── index.ts │ ├── init.ts │ ├── ob-request │ │ ├── functions.ts │ │ └── structs.ts │ ├── request │ │ ├── functions.ts │ │ └── structs.ts │ ├── transfer-request │ │ ├── functions.ts │ │ └── structs.ts │ └── withdraw-request │ │ ├── functions.ts │ │ └── structs.ts └── utils │ ├── crit-bit │ ├── functions.ts │ └── structs.ts │ ├── display │ └── functions.ts │ ├── dynamic-vector │ ├── functions.ts │ └── structs.ts │ ├── index.ts │ ├── init.ts │ ├── math │ └── functions.ts │ ├── sized-vec │ ├── functions.ts │ └── structs.ts │ ├── utils-supply │ ├── functions.ts │ └── structs.ts │ └── utils │ ├── functions.ts │ └── structs.ts ├── contracts ├── allowlist │ ├── Move.lock │ ├── Move.toml │ ├── sources │ │ ├── allowlist │ │ │ └── allowlist.move │ │ ├── init.move │ │ └── pub.move │ └── tests │ │ └── allowlist.move ├── authlist │ ├── Move.lock │ ├── Move.toml │ ├── sources │ │ ├── authlist │ │ │ └── authlist.move │ │ ├── init.move │ │ └── pub.move │ └── tests │ │ └── authlist.move ├── critbit │ ├── Move.lock │ ├── Move.toml │ ├── README.md │ ├── sources │ │ └── critbit_u64.move │ └── tests │ │ └── critbit_u64.move ├── kiosk │ ├── Move.lock │ ├── Move.toml │ └── sources │ │ ├── init.move │ │ ├── kiosk │ │ └── ob_kiosk.move │ │ └── pub.move ├── launchpad │ ├── Move.lock │ ├── Move.toml │ ├── sources │ │ ├── init.move │ │ ├── launchpad │ │ │ ├── fees │ │ │ │ └── flat_fee.move │ │ │ ├── inventory.move │ │ │ ├── listing.move │ │ │ ├── market │ │ │ │ ├── dutch_auction.move │ │ │ │ ├── english_auction.move │ │ │ │ ├── fixed_price.move │ │ │ │ └── limited_fixed_price.move │ │ │ ├── market_whitelist.move │ │ │ ├── marketplace.move │ │ │ ├── proceeds.move │ │ │ ├── rebate.move │ │ │ ├── venue.move │ │ │ └── warehouse.move │ │ └── pub.move │ └── tests │ │ ├── delegation.move │ │ ├── fees.move │ │ ├── listing.move │ │ ├── market │ │ ├── dutch_auction.move │ │ ├── english_auction.move │ │ ├── fixed_price.move │ │ └── limited_fixed_price.move │ │ ├── mint_and_sell.move │ │ ├── rebate.move │ │ ├── warehouse.move │ │ ├── whitelist_with_cert.move │ │ └── whitelist_with_set.move ├── liquidity_layer_v1 │ ├── Move.lock │ ├── Move.toml │ └── sources │ │ ├── init.move │ │ ├── pub.move │ │ └── trading │ │ ├── bidding.move │ │ ├── orderbook.move │ │ └── trading.move ├── nft_protocol │ ├── Move.lock │ ├── Move.toml │ ├── sources │ │ ├── collection │ │ │ ├── collection.move │ │ │ ├── mint_cap.move │ │ │ ├── mint_event.move │ │ │ ├── mint_pass.move │ │ │ └── nft_wrapper.move │ │ ├── init.move │ │ ├── pub.move │ │ ├── rules │ │ │ ├── access_policy.move │ │ │ ├── deprecated │ │ │ │ └── session_tokens.move │ │ │ ├── p2p_list.move │ │ │ ├── royalty_strategy.move │ │ │ ├── transfer_allowlist.move │ │ │ └── transfer_token.move │ │ └── standards │ │ │ ├── allowlist.move │ │ │ ├── attributes.move │ │ │ ├── authlist.move │ │ │ ├── composability │ │ │ ├── composable_nft.move │ │ │ ├── nft_bag.move │ │ │ ├── svg.move │ │ │ └── url.move │ │ │ ├── creators.move │ │ │ ├── display_info.move │ │ │ ├── mint_supply.move │ │ │ ├── plugins.move │ │ │ ├── royalty.move │ │ │ ├── supply.move │ │ │ ├── svg.move │ │ │ ├── symbol.move │ │ │ ├── tags.move │ │ │ └── url.move │ └── tests │ │ └── rules │ │ └── p2p.move ├── originmate │ ├── CHANGELOG.md │ ├── Move.lock │ ├── Move.toml │ ├── README.md │ └── sources │ │ ├── balances.move │ │ ├── bloom_filter.move │ │ ├── box.move │ │ ├── crit_bit.move │ │ ├── crit_bit_u64.move │ │ ├── date.move │ │ ├── escrow.move │ │ ├── escrow_shared.move │ │ ├── i128_type.move │ │ ├── i64_type.move │ │ ├── linear_vesting.move │ │ ├── math.move │ │ ├── math_safe_precise.move │ │ ├── math_u128.move │ │ ├── merkle_proof.move │ │ ├── object_box.move │ │ ├── object_vec.move │ │ ├── quadratic_vesting.move │ │ ├── to_string.move │ │ ├── typed_id.move │ │ └── vectors.move ├── permissions │ ├── Move.lock │ ├── Move.toml │ ├── sources │ │ ├── init.move │ │ ├── permissions │ │ │ ├── frozen_publisher.move │ │ │ ├── quorum.move │ │ │ └── witness.move │ │ └── pub.move │ └── tests │ │ ├── quorum.move │ │ └── witness.move ├── pseudorandom │ ├── Move.lock │ ├── Move.toml │ └── sources │ │ └── pseudorandom.move ├── request │ ├── Move.lock │ ├── Move.toml │ └── sources │ │ ├── init.move │ │ ├── pub.move │ │ └── request │ │ ├── policies │ │ ├── borrow.move │ │ ├── transfer.move │ │ └── withdraw.move │ │ └── request.move ├── tests │ ├── Move.toml │ ├── sources │ │ └── .gitkeep │ └── tests │ │ ├── domains │ │ ├── composability │ │ │ ├── composable_nft.move │ │ │ ├── nft_bag.move │ │ │ └── svg.move │ │ ├── creators.move │ │ ├── display.move │ │ ├── royalty.move │ │ └── tags.move │ │ ├── frozen_publisher.move │ │ ├── kiosks │ │ └── ob_kiosk.move │ │ ├── liquidity_layer_v1 │ │ ├── bidding │ │ │ └── bidding.move │ │ └── orderbook │ │ │ ├── depth.move │ │ │ ├── load.move │ │ │ ├── migration.move │ │ │ └── orderbook.move │ │ ├── mint_event.move │ │ ├── misc.move │ │ ├── permissions │ │ └── quorum.move │ │ ├── publisher.move │ │ ├── utils.move │ │ └── utils │ │ ├── utils.from_vec_to_map.move │ │ ├── utils.insert_vec_in_table.move │ │ ├── utils.insert_vec_in_vec_set.move │ │ ├── utils.sum_vector.move │ │ ├── utils.table_from_vec_map.move │ │ ├── utils.table_vec_from_vec.move │ │ ├── utils.vec_map_entries.move │ │ └── utils.vec_set_from_vec.move └── utils │ ├── Move.lock │ ├── Move.toml │ └── sources │ ├── crit_bit.move │ ├── display.move │ ├── dynamic_vec.move │ ├── math.move │ ├── sized_vec.move │ ├── supply.move │ └── utils.move ├── docs ├── archived │ ├── ALLOWLIST.md │ ├── deploy.md │ └── rfc │ │ ├── 001-safe-and-royalties.md │ │ ├── 002-off-chain-listing.md │ │ └── 003-display-standards.md └── contracts │ ├── kiosk │ └── ob_kiosk.md │ ├── launchpad │ ├── dutch_auction.md │ ├── english_auction.md │ ├── fixed_price.md │ ├── flat_fee.md │ ├── inventory.md │ ├── limited_fixed_price.md │ ├── listing.md │ ├── market_whitelist.md │ ├── marketplace.md │ ├── proceeds.md │ ├── venue.md │ └── warehouse.md │ ├── liquidity_layer │ ├── bidding.md │ ├── orderbook.md │ └── trading.md │ ├── permissions │ ├── frozen_publisher.md │ ├── quorum.md │ └── witness.md │ ├── pseudorandom │ └── pseudorandom.md │ └── request │ ├── borrow.md │ ├── request.md │ ├── transfer.md │ └── withdraw.md ├── example_collections ├── examples │ ├── Move.toml │ └── sources │ │ ├── simple.move │ │ ├── suimarines.move │ │ ├── suitraders.move │ │ ├── symbol.move │ │ ├── testract.move │ │ └── tribal_realms.move ├── loose │ ├── extended_types │ │ ├── Move.toml │ │ └── sources │ │ │ └── gun_types.move │ └── main_contract │ │ ├── Move.toml │ │ └── sources │ │ └── deadbytes.move └── swoots │ ├── Move.toml │ └── sources │ ├── collection.move │ └── traits │ ├── background.move │ ├── clothes.move │ ├── eyewear.move │ ├── face.move │ ├── fur.move │ └── head.move └── versions ├── registry-main.json └── registry-test.json /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | indent_style = space 6 | insert_final_newline = true 7 | trim_trailing_whitespace = true 8 | 9 | [*.move] 10 | indent_size = 4 11 | 12 | [*.json] 13 | indent_size = 4 14 | -------------------------------------------------------------------------------- /.env.dist: -------------------------------------------------------------------------------- 1 | SUI_VERSION="mainnet-v1.19.1" 2 | -------------------------------------------------------------------------------- /.github/config.yaml: -------------------------------------------------------------------------------- 1 | keystore: 2 | File: sui.keystore 3 | envs: 4 | - alias: devnet 5 | rpc: "https://fullnode.devnet.sui.io:443" 6 | ws: ~ 7 | active_env: devnet 8 | active_address: "0x64be9c21161c2305543e2bba67e056ebba8729e4" 9 | -------------------------------------------------------------------------------- /.github/workflows/sui-publish.yml: -------------------------------------------------------------------------------- 1 | name: sui-publish 2 | run-name: Publishing Sui packages 3 | 4 | on: workflow_dispatch 5 | 6 | jobs: 7 | publish: 8 | runs-on: ubuntu-latest 9 | 10 | steps: 11 | - uses: actions/checkout@v3 12 | 13 | - name: Setup dependencies 14 | run: | 15 | source .env.dist 16 | 17 | wget -qO sui https://github.com/MystenLabs/sui/releases/download/${SUI_VERSION}/sui 18 | chmod +x sui 19 | 20 | wget -qO stoml https://github.com/freshautomations/stoml/releases/download/v0.7.1/stoml_linux_amd64 21 | chmod +x stoml 22 | 23 | - name: Create keystore 24 | env: 25 | SUI_KEY: ${{ secrets.SUI_KEY }} 26 | run: | 27 | echo "[\"$SUI_KEY\"]" > sui.keystore 28 | 29 | - name: Publish changed packages 30 | run: | 31 | COMMIT_MSG="Published" 32 | BRANCH="publish/" 33 | 34 | for PACKAGE in `find . -name Move.toml` 35 | do 36 | # Get snake case package address 37 | NAME=`./stoml $PACKAGE package.name | sed -r 's/([A-Z])/_\L\1/g' | sed 's/^_//'` 38 | VERSION=`./stoml $PACKAGE package.version` 39 | 40 | ORIGINAL=`grep "$NAME" $PACKAGE` 41 | NEW="$NAME = \"0x0\"" 42 | 43 | # Sets the current package address to "0x0" for publishing 44 | sed -i "s/$ORIGINAL/$NEW/g" $PACKAGE 45 | 46 | # Test just in case 47 | ./sui move test --path $PACKAGE 48 | 49 | PUBLISH=`./sui client --client.config .github/config.yaml publish --gas-budget 60000 $PACKAGE --json` 50 | if [ $? -ne 0 ]; then 51 | echo $PUBLISH 52 | exit 1 53 | fi 54 | 55 | OBJECT=`echo $PUBLISH | jq '.effects.created[0].reference.objectId'` 56 | 57 | sed -i "s/$NEW/$NAME = $OBJECT/g" $PACKAGE 58 | 59 | COMMIT_MSG+=" $NAME ($VERSION)" 60 | BRANCH+="$NAME($VERSION)" 61 | done 62 | 63 | echo "COMMIT_MSG=$COMMIT_MSG" >> $GITHUB_ENV 64 | echo "BRANCH=$BRANCH" >> $GITHUB_ENV 65 | 66 | - name: Cleanup 67 | run: | 68 | rm ./sui 69 | rm ./stoml 70 | rm ./sui.keystore 71 | 72 | - name: Create Pull Request 73 | uses: peter-evans/create-pull-request@v4 74 | with: 75 | commit-message: "[skip ci] ${{ env.COMMIT_MSG }}" 76 | committer: OriginByte 77 | title: ${{ env.COMMIT_MSG }} 78 | branch: ${{ env.BRANCH }} 79 | -------------------------------------------------------------------------------- /.github/workflows/sui-test.yml: -------------------------------------------------------------------------------- 1 | name: sui-test 2 | run-name: Testing Sui packages 3 | 4 | on: 5 | pull_request: 6 | types: [ opened, synchronize ] 7 | branches: [ main, develop ] 8 | 9 | jobs: 10 | test: 11 | runs-on: ubuntu-latest 12 | 13 | steps: 14 | - uses: actions/checkout@v3 15 | 16 | - name: Get Sui SDK 17 | run: | 18 | source .env.dist 19 | 20 | wget -qO sui_folder.tgz https://github.com/MystenLabs/sui/releases/download/${SUI_VERSION}/sui-${SUI_VERSION}-ubuntu-x86_64.tgz 21 | tar -xzf sui_folder.tgz 22 | cp target/release/sui-ubuntu-x86_64 sui 23 | chmod +x sui 24 | 25 | - name: Run test for all modules 26 | run: | 27 | find . -name "Move.toml" | 28 | while read PACKAGE; do ./sui move test -p $PACKAGE --gas-limit 5000000000; done 29 | -------------------------------------------------------------------------------- /.github/workflows/update-registry-main.yml: -------------------------------------------------------------------------------- 1 | name: Update Package-Registry [Mainnet] 2 | 3 | on: 4 | workflow_dispatch: 5 | inputs: 6 | revision: 7 | description: 'Commit Hash (Defaults to last commit)' 8 | required: false 9 | 10 | jobs: 11 | update-registry: 12 | runs-on: ubuntu-latest 13 | 14 | steps: 15 | - name: Configure SSH 16 | uses: webfactory/ssh-agent@v0.5.0 17 | with: 18 | ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} 19 | 20 | - name: Extract branch name 21 | id: branch_name 22 | run: echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_ENV 23 | 24 | - name: Fetch source repository 25 | uses: actions/checkout@v2 26 | with: 27 | repository: ${{ github.repository }} 28 | ref: ${{ env.BRANCH_NAME }} 29 | path: source 30 | 31 | - name: Fetch registry repository 32 | run: | 33 | git clone git@github.com:Origin-Byte/program-registry.git program-registry 34 | 35 | - name: Setup dependencies 36 | run: | 37 | wget -qO stoml https://github.com/freshautomations/stoml/releases/download/v0.7.1/stoml_linux_amd64 38 | chmod +x stoml 39 | 40 | source source/.env.dist 41 | 42 | wget -qO sui_folder.tgz https://github.com/MystenLabs/sui/releases/download/${SUI_VERSION}/sui-${SUI_VERSION}-ubuntu-x86_64.tgz 43 | tar -xzf sui_folder.tgz 44 | cp target/release/sui-ubuntu-x86_64 sui 45 | chmod +x sui 46 | echo "installed" 47 | 48 | - name: Build Packages 49 | run: | 50 | echo "Building packages" 51 | cd source 52 | 53 | ./bin/build.sh remote 54 | cd .. 55 | 56 | - name: Copy registry to local fs 57 | run: | 58 | echo "Copying registry to local file system" 59 | cp program-registry/registry-main.json registry-main.json 60 | 61 | - name: Update local Package Registry 62 | env: 63 | REVISION: ${{ github.event.inputs.revision || github.sha }} 64 | run: | 65 | echo $(ls) 66 | echo "Registering under revision: $REVISION" 67 | ./source/bin/register-all.sh ${{ github.repository }} $REVISION source remote registry-main.json 68 | 69 | - name: Update remote registry 70 | run: | 71 | echo "Updating Main Package Registry" 72 | cp registry-main.json program-registry/registry-main.json 73 | cd program-registry 74 | git add registry-main.json 75 | git config user.name "OriginByte" 76 | git config user.email "ci@originbyte.io" 77 | git commit -m "Update Main Registry" 78 | git push 79 | -------------------------------------------------------------------------------- /.github/workflows/update-registry-test.yml: -------------------------------------------------------------------------------- 1 | name: Update Package-Registry [Testnet] 2 | 3 | on: 4 | workflow_dispatch: 5 | inputs: 6 | revision: 7 | description: 'Commit Hash (Defaults to last commit)' 8 | required: false 9 | 10 | jobs: 11 | update-registry: 12 | runs-on: ubuntu-latest 13 | 14 | steps: 15 | - name: Configure SSH 16 | uses: webfactory/ssh-agent@v0.5.0 17 | with: 18 | ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} 19 | 20 | - name: Extract branch name 21 | id: branch_name 22 | run: echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_ENV 23 | 24 | - name: Fetch source repository 25 | uses: actions/checkout@v2 26 | with: 27 | repository: ${{ github.repository }} 28 | ref: ${{ env.BRANCH_NAME }} 29 | path: source 30 | 31 | - name: Fetch registry repository 32 | run: | 33 | git clone git@github.com:Origin-Byte/program-registry.git program-registry 34 | 35 | - name: Setup dependencies 36 | run: | 37 | wget -qO stoml https://github.com/freshautomations/stoml/releases/download/v0.7.1/stoml_linux_amd64 38 | chmod +x stoml 39 | 40 | source source/.env.dist 41 | 42 | wget -qO sui_folder.tgz https://github.com/MystenLabs/sui/releases/download/${SUI_VERSION}/sui-${SUI_VERSION}-ubuntu-x86_64.tgz 43 | tar -xzf sui_folder.tgz 44 | cp target/release/sui-ubuntu-x86_64 sui 45 | chmod +x sui 46 | echo "installed" 47 | 48 | - name: Build Packages 49 | run: | 50 | echo "Building packages" 51 | cd source 52 | 53 | ./bin/build.sh remote 54 | cd .. 55 | 56 | - name: Copy registry to local fs 57 | run: | 58 | echo "Copying registry to local file system" 59 | cp program-registry/registry-test.json registry-test.json 60 | 61 | - name: Update local Package Registry 62 | env: 63 | REVISION: ${{ github.event.inputs.revision || github.sha }} 64 | run: | 65 | echo $(ls) 66 | echo "Registering under revision: $REVISION" 67 | ./source/bin/register-all.sh ${{ github.repository }} $REVISION source remote registry-test.json 68 | 69 | - name: Update remote registry 70 | run: | 71 | echo "Updating Test Package Registry" 72 | cp registry-test.json program-registry/registry-test.json 73 | cd program-registry 74 | git add registry-test.json 75 | git config user.name "OriginByte" 76 | git config user.email "ci@originbyte.io" 77 | git commit -m "Update Test Registry" 78 | git push 79 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .vscode 2 | 3 | sui.log.* 4 | .env 5 | .env.caps.* 6 | .env.pubs 7 | build 8 | target 9 | output.bpl 10 | .coverage_* 11 | .trace 12 | boilerplate 13 | .DS_Store 14 | local 15 | unpublished 16 | bin/pub.py 17 | logs 18 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | VIRAL PUBLIC LICENSE 2 | Copyleft (ɔ) All Rights Reversed 3 | 4 | This WORK is hereby relinquished of all associated ownership, attribution and copy rights, and redistribution or use of any kind, with or without modification, is permitted without restriction subject to the following conditions: 5 | 6 | 1. Redistributions of this WORK, or ANY work that makes use of ANY of the contents of this WORK by ANY kind of copying, dependency, linkage, or ANY other possible form of DERIVATION or COMBINATION, must retain the ENTIRETY of this license. 7 | 2. No further restrictions of ANY kind may be applied. 8 | Fully permissive, viral software license. The VPL is designed to achieve and extend the GPL's strong copyleft without the burden of its obligations and restrictions. The VPL's sole restriction is its own viral continuity, allowing it to effectively and permanently infect any work it touches with absolute permissiveness. 9 | -------------------------------------------------------------------------------- /assets/3_layer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Origin-Byte/nft-protocol/e8e8efd77ab15d7b2cf30958fd748dbb3afbdaab/assets/3_layer.png -------------------------------------------------------------------------------- /assets/display.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Origin-Byte/nft-protocol/e8e8efd77ab15d7b2cf30958fd748dbb3afbdaab/assets/display.png -------------------------------------------------------------------------------- /assets/logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /bin/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ "$1" = "remote" ]; then 4 | echo "Running script in remote setup" 5 | sui="./../../../sui" 6 | else 7 | echo "Running script in local setup" 8 | sui="sui" 9 | fi 10 | 11 | 12 | cd ./contracts/allowlist 13 | ${sui} move build 14 | cd .. 15 | 16 | cd ./request 17 | ${sui} move build 18 | cd .. 19 | 20 | cd ./authlist 21 | ${sui} move build 22 | cd .. 23 | 24 | cd ./permissions 25 | ${sui} move build 26 | cd .. 27 | 28 | cd ./pseudorandom 29 | ${sui} move build 30 | cd .. 31 | 32 | cd ./utils 33 | ${sui} move build 34 | cd .. 35 | 36 | ls 37 | 38 | cd ./critbit 39 | ${sui} move build 40 | cd .. 41 | 42 | cd ./originmate 43 | ${sui} move build 44 | cd .. 45 | 46 | cd ./kiosk 47 | ${sui} move build 48 | cd .. 49 | 50 | cd ./launchpad 51 | ${sui} move build 52 | cd .. 53 | 54 | cd ./liquidity_layer_v1 55 | ${sui} move build 56 | cd .. 57 | 58 | cd ./nft_protocol 59 | ${sui} move build 60 | 61 | cd ../.. 62 | -------------------------------------------------------------------------------- /bin/clean.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | find . -name "Move.lock" -exec rm -rf {} \; 4 | find . -type d -name build -exec rm -rf {} \; 5 | -------------------------------------------------------------------------------- /bin/gen_client.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Navigate to the target directory 4 | cd client/ 5 | 6 | # Find and delete all files and directories except gem.toml 7 | find . -type f ! -name 'gen.toml' -exec rm -f {} + 8 | 9 | sui-client-gen 10 | 11 | pnpm eslint . --fix 12 | 13 | cd ../ 14 | -------------------------------------------------------------------------------- /bin/publish.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # 4 | # Publishes a package into a new address. Assumes that Sui is running. 5 | # 6 | 7 | env=$(cat .env) 8 | if [ -n "${env}" ]; then 9 | export $(echo "${env}" | xargs) 10 | fi 11 | 12 | budget="30000" 13 | if [ -z "${GAS}" ]; then 14 | sui client publish --gas-budget "${budget}" . 15 | else 16 | sui client publish \ 17 | --gas "${GAS}" \ 18 | --gas-budget "${budget}" . 19 | fi 20 | -------------------------------------------------------------------------------- /bin/register-all.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Get the directory path of the current script 4 | script_dir=$(dirname "$0") 5 | 6 | # Source the other script using a relative path 7 | source "$script_dir/register.sh" 8 | source "$script_dir/mappings.sh" 9 | 10 | # To avoid silent errors 11 | set -e 12 | 13 | repo=$1 14 | rev=$2 15 | source_folder="${3}/contracts" 16 | registry_path="${5}" 17 | 18 | if [ "$4" = "remote" ]; then 19 | echo "Running script in remote setup" 20 | stoml="./stoml" 21 | else 22 | echo "Running script in local setup" 23 | stoml="stoml" 24 | fi 25 | 26 | registry=$(jq '.' $registry_path) 27 | files=$(find $source_folder -name "Move.toml") 28 | 29 | for file in $files; do 30 | address=$(${stoml} ${file} addresses) 31 | 32 | if [[ $address == "ob_launchpad_v2" || $address == "ob_tests" || $address == "liquidity_layer" ]]; then 33 | continue # Ignore addresses 34 | fi 35 | 36 | object_id=$(${stoml} ${file} addresses.${address}) 37 | version=$(${stoml} ${file} package.version) 38 | name=$(with_prefix_to_pascal ${address}) 39 | 40 | pkg_versions=$(jq --arg name "$name" '.[$name]' <<< "$registry") 41 | has_version=$(jq --arg version "$version" 'has($version)' <<< "$pkg_versions") 42 | 43 | if [ "$has_version" = true ]; then 44 | echo "$name version $version already exists" 45 | continue 46 | fi 47 | 48 | mod_name=$(remove_prefix ${address}) 49 | 50 | register ${mod_name} ${repo} ${rev} $3 $4 ${registry_path} 51 | 52 | done 53 | -------------------------------------------------------------------------------- /bin/reset_tomls.py: -------------------------------------------------------------------------------- 1 | def reset_toml(file_path): 2 | with open(file_path, 'r') as file: 3 | lines = file.readlines() 4 | 5 | in_addresses_section = False 6 | address_modified = False 7 | 8 | with open(file_path, 'w') as file: 9 | for line in lines: 10 | if line.strip() == '[addresses]': 11 | in_addresses_section = True 12 | elif in_addresses_section and '=' in line and not address_modified: 13 | key = line.split('=')[0].strip() 14 | file.write('#' + line) # Comment out the existing line 15 | file.write(f'{key} = "0x"\n') # Add new line with '0x' 16 | address_modified = True 17 | continue 18 | elif line.strip().startswith('[') and in_addresses_section: 19 | in_addresses_section = False 20 | 21 | file.write(line) 22 | 23 | # Replace 'path_to_file.toml' with the actual path to your Move.toml file 24 | reset_toml('contracts/pseudorandom/Move.toml') 25 | reset_toml('contracts/utils/Move.toml') 26 | reset_toml('contracts/permissions/Move.toml') 27 | reset_toml('contracts/request/Move.toml') 28 | reset_toml('contracts/allowlist/Move.toml') 29 | reset_toml('contracts/authlist/Move.toml') 30 | reset_toml('contracts/critbit/Move.toml') 31 | reset_toml('contracts/originmate/Move.toml') 32 | reset_toml('contracts/kiosk/Move.toml') 33 | reset_toml('contracts/nft_protocol/Move.toml') 34 | reset_toml('contracts/liquidity_layer_v1/Move.toml') 35 | reset_toml('contracts/launchpad/Move.toml') 36 | -------------------------------------------------------------------------------- /bin/test.sh: -------------------------------------------------------------------------------- 1 | find . -name "Move.toml" -not -path "./local/*" | 2 | while read PACKAGE; do sui move test -p $PACKAGE --gas-limit 5000000000; done 3 | -------------------------------------------------------------------------------- /bin/update_docs.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | def generate_contracts_list(file_path): 4 | package_name = None 5 | published_at = None 6 | contracts_list = [] 7 | 8 | with open(file_path, 'r') as file: 9 | lines = file.readlines() 10 | 11 | for line in lines: 12 | if line.strip().startswith('[package]'): 13 | package_section = True 14 | elif package_section and 'name' in line: 15 | package_name = line.split('=')[1].strip().strip('"') 16 | elif package_section and 'published-at' in line: 17 | published_at = line.split('=')[1].strip().strip('"') 18 | contracts_list.append((package_name, published_at)) 19 | package_section = False 20 | 21 | return contracts_list 22 | 23 | def update_readme_with_contracts(contracts): 24 | readme_path = 'README.md' 25 | updated_lines = [] 26 | with open(readme_path, 'r') as file: 27 | lines = file.readlines() 28 | 29 | contracts_section = False 30 | in_contracts_list = False # Flag to track whether we're adding contracts 31 | for line in lines: 32 | if line.strip() == '## Contracts': 33 | contracts_section = True 34 | in_contracts_list = True # Start adding contracts 35 | updated_lines.append(line) 36 | updated_lines.append('\n- Protocol contracts:\n') 37 | for package_name, published_at in contracts: 38 | updated_lines.append(f' - [{package_name}](https://explorer.sui.io/object/{published_at})\n') 39 | updated_lines.append('\n') # Ensure an empty line after the list 40 | continue 41 | if contracts_section and line.strip().startswith('##'): 42 | contracts_section = False 43 | if in_contracts_list: 44 | in_contracts_list = False # Finished adding contracts, add an extra newline for spacing 45 | updated_lines.append('\n') # Add an extra newline before the next section header 46 | if not contracts_section or not in_contracts_list: 47 | updated_lines.append(line) 48 | 49 | with open(readme_path, 'w') as file: 50 | file.writelines(updated_lines) 51 | 52 | contracts_files = [ 53 | 'contracts/pseudorandom/Move.toml', 54 | 'contracts/utils/Move.toml', 55 | 'contracts/permissions/Move.toml', 56 | 'contracts/request/Move.toml', 57 | 'contracts/allowlist/Move.toml', 58 | 'contracts/authlist/Move.toml', 59 | 'contracts/critbit/Move.toml', 60 | 'contracts/originmate/Move.toml', 61 | 'contracts/kiosk/Move.toml', 62 | 'contracts/nft_protocol/Move.toml', 63 | 'contracts/liquidity_layer_v1/Move.toml', 64 | 'contracts/launchpad/Move.toml', 65 | ] 66 | 67 | all_contracts = [] 68 | for file_path in contracts_files: 69 | all_contracts.extend(generate_contracts_list(file_path)) 70 | 71 | update_readme_with_contracts(all_contracts) 72 | -------------------------------------------------------------------------------- /client/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | "@typescript-eslint/ban-types": "off", 4 | "@typescript-eslint/no-explicit-any": "off", 5 | "@typescript-eslint/no-unused-vars": "off" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /client/_dependencies/source/0x1/index.ts: -------------------------------------------------------------------------------- 1 | export const PACKAGE_ID = "0x1"; 2 | export const PUBLISHED_AT = "0x1"; 3 | -------------------------------------------------------------------------------- /client/_dependencies/source/0x1/init.ts: -------------------------------------------------------------------------------- 1 | import * as ascii from "./ascii/structs"; 2 | import * as bitVector from "./bit-vector/structs"; 3 | import * as fixedPoint32 from "./fixed-point32/structs"; 4 | import * as option from "./option/structs"; 5 | import * as string from "./string/structs"; 6 | import * as typeName from "./type-name/structs"; 7 | import {StructClassLoader} from "../../../_framework/loader"; 8 | 9 | export function registerClasses(loader: StructClassLoader) { 10 | loader.register(fixedPoint32.FixedPoint32); 11 | loader.register(option.Option); 12 | loader.register(ascii.Char); 13 | loader.register(ascii.String); 14 | loader.register(bitVector.BitVector); 15 | loader.register(string.String); 16 | loader.register(typeName.TypeName); 17 | } 18 | -------------------------------------------------------------------------------- /client/_dependencies/source/0x2/index.ts: -------------------------------------------------------------------------------- 1 | export const PACKAGE_ID = "0x2"; 2 | export const PUBLISHED_AT = "0x2"; 3 | -------------------------------------------------------------------------------- /client/_framework/init-source.ts: -------------------------------------------------------------------------------- 1 | import * as package_1 from "../_dependencies/source/0x1/init"; 2 | import * as package_2 from "../_dependencies/source/0x2/init"; 3 | import * as package_70e34fcd390b767edbddaf7573450528698188c84c5395af8c4b12e3e37622fa from "../allowlist/init"; 4 | import * as package_228b48911fdc05f8d80ac4334cd734d38dd7db74a0f4e423cb91f736f429ebe4 from "../authlist/init"; 5 | import * as package_5fb957b59e6b093c17eb3f0ca0a3e8762530244f39f738bd356dbdd43ed9230e from "../critbit/init"; 6 | import * as package_95a441d389b07437d00dd07e0b6f05f513d7659b13fd7c5d3923c7d9d847199b from "../kiosk/init"; 7 | import * as package_c74531639fadfb02d30f05f37de4cf1e1149ed8d23658edd089004830068180b from "../launchpad/init"; 8 | import * as package_4e0629fa51a62b0c1d7c7b9fc89237ec5b6f630d7798ad3f06d820afb93a995a from "../liquidity-layer-v-1/init"; 9 | import * as package_bc3df36be17f27ac98e3c839b2589db8475fa07b20657b08e8891e3aaf5ee5f9 from "../nft-protocol/init"; 10 | import * as package_ed6c6fe0732be937f4379bc0b471f0f6bfbe0e8741968009e0f01e6de3d59f32 from "../originmate/init"; 11 | import * as package_16c5f17f2d55584a6e6daa442ccf83b4530d10546a8e7dedda9ba324e012fc40 from "../permissions/init"; 12 | import * as package_9e5962d5183664be8a7762fbe94eee6e3457c0cc701750c94c17f7f8ac5a32fb from "../pseudorandom/init"; 13 | import * as package_e2c7a6843cb13d9549a9d2dc1c266b572ead0b4b9f090e7c3c46de2714102b43 from "../request/init"; 14 | import * as package_859eb18bd5b5e8cc32deb6dfb1c39941008ab3c6e27f0b8ce2364be7102bb7cb from "../utils/init"; 15 | import {structClassLoaderSource as structClassLoader} from "./loader"; 16 | 17 | let initialized = false; 18 | 19 | export function initLoaderIfNeeded() { 20 | if (initialized) { 21 | return 22 | }; 23 | initialized = true; 24 | 25 | package_1.registerClasses(structClassLoader); 26 | package_2.registerClasses(structClassLoader); 27 | package_16c5f17f2d55584a6e6daa442ccf83b4530d10546a8e7dedda9ba324e012fc40.registerClasses(structClassLoader); 28 | package_228b48911fdc05f8d80ac4334cd734d38dd7db74a0f4e423cb91f736f429ebe4.registerClasses(structClassLoader); 29 | package_4e0629fa51a62b0c1d7c7b9fc89237ec5b6f630d7798ad3f06d820afb93a995a.registerClasses(structClassLoader); 30 | package_5fb957b59e6b093c17eb3f0ca0a3e8762530244f39f738bd356dbdd43ed9230e.registerClasses(structClassLoader); 31 | package_70e34fcd390b767edbddaf7573450528698188c84c5395af8c4b12e3e37622fa.registerClasses(structClassLoader); 32 | package_859eb18bd5b5e8cc32deb6dfb1c39941008ab3c6e27f0b8ce2364be7102bb7cb.registerClasses(structClassLoader); 33 | package_95a441d389b07437d00dd07e0b6f05f513d7659b13fd7c5d3923c7d9d847199b.registerClasses(structClassLoader); 34 | package_9e5962d5183664be8a7762fbe94eee6e3457c0cc701750c94c17f7f8ac5a32fb.registerClasses(structClassLoader); 35 | package_bc3df36be17f27ac98e3c839b2589db8475fa07b20657b08e8891e3aaf5ee5f9.registerClasses(structClassLoader); 36 | package_c74531639fadfb02d30f05f37de4cf1e1149ed8d23658edd089004830068180b.registerClasses(structClassLoader); 37 | package_e2c7a6843cb13d9549a9d2dc1c266b572ead0b4b9f090e7c3c46de2714102b43.registerClasses(structClassLoader); 38 | package_ed6c6fe0732be937f4379bc0b471f0f6bfbe0e8741968009e0f01e6de3d59f32.registerClasses(structClassLoader); 39 | } 40 | -------------------------------------------------------------------------------- /client/_framework/loader.ts: -------------------------------------------------------------------------------- 1 | 2 | import { compressSuiType, parseTypeName } from './util' 3 | import { 4 | PhantomReified, 5 | PhantomTypeArgument, 6 | Primitive, 7 | Reified, 8 | StructClass, 9 | StructClassReified, 10 | TypeArgument, 11 | VectorClass, 12 | VectorClassReified, 13 | vector, 14 | } from './reified' 15 | 16 | export type PrimitiveValue = string | number | boolean | bigint 17 | 18 | interface _StructClass { 19 | $typeName: string 20 | $numTypeParams: number 21 | reified( 22 | ...Ts: Array | PhantomReified> 23 | ): StructClassReified 24 | } 25 | 26 | export class StructClassLoader { 27 | private map: Map = new Map() 28 | 29 | register(...classes: _StructClass[]) { 30 | for (const cls of classes) { 31 | this.map.set(cls.$typeName, cls) 32 | } 33 | } 34 | 35 | reified(type: T): T 36 | reified(type: `vector<${string}>`): VectorClassReified 37 | reified(type: string): StructClassReified 38 | reified( 39 | type: string 40 | ): StructClassReified | VectorClassReified | string { 41 | const { typeName, typeArgs } = parseTypeName(compressSuiType(type)) 42 | switch (typeName) { 43 | case 'bool': 44 | case 'u8': 45 | case 'u16': 46 | case 'u32': 47 | case 'u64': 48 | case 'u128': 49 | case 'u256': 50 | case 'address': 51 | return typeName 52 | case 'vector': { 53 | if (typeArgs.length !== 1) { 54 | throw new Error(`Vector expects 1 type argument, but got ${typeArgs.length}`) 55 | } 56 | return vector(this.reified(typeArgs[0])) 57 | } 58 | } 59 | 60 | if (!this.map.has(typeName)) { 61 | throw new Error(`Unknown type ${typeName}`) 62 | } 63 | 64 | const cls = this.map.get(typeName)! 65 | if (cls.$numTypeParams !== typeArgs.length) { 66 | throw new Error( 67 | `Type ${typeName} expects ${cls.$numTypeParams} type arguments, but got ${typeArgs.length}` 68 | ) 69 | } 70 | 71 | return cls.reified(...typeArgs.map(t => this.reified(t))) 72 | } 73 | } 74 | 75 | export const structClassLoaderSource = new StructClassLoader() 76 | export const structClassLoaderOnchain = new StructClassLoader() 77 | 78 | -------------------------------------------------------------------------------- /client/allowlist/frozen-pub/functions.ts: -------------------------------------------------------------------------------- 1 | import {PUBLISHED_AT} from ".."; 2 | import {ObjectArg, obj} from "../../_framework/util"; 3 | import {TransactionBlock} from "@mysten/sui.js/transactions"; 4 | 5 | export function init( 6 | txb: TransactionBlock, 7 | otw: ObjectArg 8 | ) { 9 | return txb.moveCall({ 10 | target: `${PUBLISHED_AT}::frozen_pub::init`, 11 | arguments: [ 12 | obj(txb, otw) 13 | ], 14 | }) 15 | } 16 | -------------------------------------------------------------------------------- /client/allowlist/index.ts: -------------------------------------------------------------------------------- 1 | export const PACKAGE_ID = "0x70e34fcd390b767edbddaf7573450528698188c84c5395af8c4b12e3e37622fa"; 2 | export const PUBLISHED_AT = "0x58c01ad7908a1c5ffbd70d89ac33e83cb554b828d69a7772246ae386bd62b5a7"; 3 | -------------------------------------------------------------------------------- /client/allowlist/init.ts: -------------------------------------------------------------------------------- 1 | import * as allowlist from "./allowlist/structs"; 2 | import * as frozenPub from "./frozen-pub/structs"; 3 | import * as obAllowlist from "./ob-allowlist/structs"; 4 | import {StructClassLoader} from "../_framework/loader"; 5 | 6 | export function registerClasses(loader: StructClassLoader) { 7 | loader.register(allowlist.CollectionKey); 8 | loader.register(allowlist.ALLOWLIST); 9 | loader.register(allowlist.Allowlist); 10 | loader.register(allowlist.AllowlistOwnerCap); 11 | loader.register(frozenPub.FROZEN_PUB); 12 | loader.register(obAllowlist.OB_ALLOWLIST); 13 | } 14 | -------------------------------------------------------------------------------- /client/allowlist/ob-allowlist/functions.ts: -------------------------------------------------------------------------------- 1 | import {PUBLISHED_AT} from ".."; 2 | import {ObjectArg, obj} from "../../_framework/util"; 3 | import {TransactionBlock} from "@mysten/sui.js/transactions"; 4 | 5 | export function init( 6 | txb: TransactionBlock, 7 | otw: ObjectArg 8 | ) { 9 | return txb.moveCall({ 10 | target: `${PUBLISHED_AT}::ob_allowlist::init`, 11 | arguments: [ 12 | obj(txb, otw) 13 | ], 14 | }) 15 | } 16 | -------------------------------------------------------------------------------- /client/authlist/frozen-pub/functions.ts: -------------------------------------------------------------------------------- 1 | import {PUBLISHED_AT} from ".."; 2 | import {ObjectArg, obj} from "../../_framework/util"; 3 | import {TransactionBlock} from "@mysten/sui.js/transactions"; 4 | 5 | export function init( 6 | txb: TransactionBlock, 7 | otw: ObjectArg 8 | ) { 9 | return txb.moveCall({ 10 | target: `${PUBLISHED_AT}::frozen_pub::init`, 11 | arguments: [ 12 | obj(txb, otw) 13 | ], 14 | }) 15 | } 16 | -------------------------------------------------------------------------------- /client/authlist/index.ts: -------------------------------------------------------------------------------- 1 | export const PACKAGE_ID = "0x228b48911fdc05f8d80ac4334cd734d38dd7db74a0f4e423cb91f736f429ebe4"; 2 | export const PUBLISHED_AT = "0x4e95600adb05c72bd2caefac7cfda17ca9ccd78846a15663b06662258761b81a"; 3 | -------------------------------------------------------------------------------- /client/authlist/init.ts: -------------------------------------------------------------------------------- 1 | import * as authlist from "./authlist/structs"; 2 | import * as frozenPub from "./frozen-pub/structs"; 3 | import * as obAuthlist from "./ob-authlist/structs"; 4 | import {StructClassLoader} from "../_framework/loader"; 5 | 6 | export function registerClasses(loader: StructClassLoader) { 7 | loader.register(authlist.AUTHLIST); 8 | loader.register(authlist.Authlist); 9 | loader.register(authlist.AuthlistOwnerCap); 10 | loader.register(authlist.CollectionKey); 11 | loader.register(frozenPub.FROZEN_PUB); 12 | loader.register(obAuthlist.OB_AUTHLIST); 13 | } 14 | -------------------------------------------------------------------------------- /client/authlist/ob-authlist/functions.ts: -------------------------------------------------------------------------------- 1 | import {PUBLISHED_AT} from ".."; 2 | import {ObjectArg, obj} from "../../_framework/util"; 3 | import {TransactionBlock} from "@mysten/sui.js/transactions"; 4 | 5 | export function init( 6 | txb: TransactionBlock, 7 | otw: ObjectArg 8 | ) { 9 | return txb.moveCall({ 10 | target: `${PUBLISHED_AT}::ob_authlist::init`, 11 | arguments: [ 12 | obj(txb, otw) 13 | ], 14 | }) 15 | } 16 | -------------------------------------------------------------------------------- /client/critbit/index.ts: -------------------------------------------------------------------------------- 1 | export const PACKAGE_ID = "0x5fb957b59e6b093c17eb3f0ca0a3e8762530244f39f738bd356dbdd43ed9230e"; 2 | export const PUBLISHED_AT = "0x7bbef8a8a7b3065cd4c4d0b56a7f7f09db40fb320a4ea5c286ff8f671ebd0873"; 3 | -------------------------------------------------------------------------------- /client/critbit/init.ts: -------------------------------------------------------------------------------- 1 | import * as critbitU64 from "./critbit-u64/structs"; 2 | import {StructClassLoader} from "../_framework/loader"; 3 | 4 | export function registerClasses(loader: StructClassLoader) { 5 | loader.register(critbitU64.CritbitTree); 6 | loader.register(critbitU64.InternalNode); 7 | loader.register(critbitU64.Leaf); 8 | } 9 | -------------------------------------------------------------------------------- /client/gen.toml: -------------------------------------------------------------------------------- 1 | [config] 2 | # will be set to mainnet by default if omitted 3 | #rpc = "https://fullnode.devnet.sui.io:443" 4 | 5 | [packages] 6 | # based on source code (syntax same as in Move.toml): 7 | Allowlist = { local = "../contracts/allowlist" } 8 | Authlist = { local = "../contracts/authlist" } 9 | Critbit = { local = "../contracts/critbit" } 10 | Kiosk = { local = "../contracts/kiosk" } 11 | Launchpad = { local = "../contracts/launchpad" } 12 | LiquidityLayerV1 = { local = "../contracts/liquidity_layer_v1" } 13 | NftProtocol = { local = "../contracts/nft_protocol" } 14 | Originmate = { local = "../contracts/originmate" } 15 | Permissions = { local = "../contracts/permissions" } 16 | Pseudorandom = { local = "../contracts/pseudorandom" } 17 | Request = { local = "../contracts/request" } 18 | Utils = { local = "../contracts/utils" } 19 | -------------------------------------------------------------------------------- /client/kiosk/frozen-pub/functions.ts: -------------------------------------------------------------------------------- 1 | import {PUBLISHED_AT} from ".."; 2 | import {ObjectArg, obj} from "../../_framework/util"; 3 | import {TransactionBlock} from "@mysten/sui.js/transactions"; 4 | 5 | export function init( 6 | txb: TransactionBlock, 7 | otw: ObjectArg 8 | ) { 9 | return txb.moveCall({ 10 | target: `${PUBLISHED_AT}::frozen_pub::init`, 11 | arguments: [ 12 | obj(txb, otw) 13 | ], 14 | }) 15 | } 16 | -------------------------------------------------------------------------------- /client/kiosk/index.ts: -------------------------------------------------------------------------------- 1 | export const PACKAGE_ID = "0x95a441d389b07437d00dd07e0b6f05f513d7659b13fd7c5d3923c7d9d847199b"; 2 | export const PUBLISHED_AT = "0x2678c98fe23173eebea384509464eb81b1f3035a57419cb46d025000c337451a"; 3 | -------------------------------------------------------------------------------- /client/kiosk/init.ts: -------------------------------------------------------------------------------- 1 | import * as frozenPub from "./frozen-pub/structs"; 2 | import * as kiosk from "./kiosk/structs"; 3 | import * as obKiosk from "./ob-kiosk/structs"; 4 | import {StructClassLoader} from "../_framework/loader"; 5 | 6 | export function registerClasses(loader: StructClassLoader) { 7 | loader.register(kiosk.KIOSK); 8 | loader.register(obKiosk.Witness); 9 | loader.register(obKiosk.AuthTransferRequestDfKey); 10 | loader.register(obKiosk.DepositSetting); 11 | loader.register(obKiosk.DepositSettingDfKey); 12 | loader.register(obKiosk.KioskOwnerCapDfKey); 13 | loader.register(obKiosk.NftRef); 14 | loader.register(obKiosk.NftRefsDfKey); 15 | loader.register(obKiosk.OB_KIOSK); 16 | loader.register(obKiosk.OwnerToken); 17 | loader.register(obKiosk.VersionDfKey); 18 | loader.register(frozenPub.FROZEN_PUB); 19 | } 20 | -------------------------------------------------------------------------------- /client/kiosk/kiosk/functions.ts: -------------------------------------------------------------------------------- 1 | import {PUBLISHED_AT} from ".."; 2 | import {ObjectArg, obj} from "../../_framework/util"; 3 | import {TransactionBlock} from "@mysten/sui.js/transactions"; 4 | 5 | export function init( 6 | txb: TransactionBlock, 7 | otw: ObjectArg 8 | ) { 9 | return txb.moveCall({ 10 | target: `${PUBLISHED_AT}::kiosk::init`, 11 | arguments: [ 12 | obj(txb, otw) 13 | ], 14 | }) 15 | } 16 | -------------------------------------------------------------------------------- /client/launchpad/flat-fee/functions.ts: -------------------------------------------------------------------------------- 1 | import {PUBLISHED_AT} from ".."; 2 | import {ObjectArg, obj, pure} from "../../_framework/util"; 3 | import {TransactionArgument, TransactionBlock} from "@mysten/sui.js/transactions"; 4 | 5 | export function new_( 6 | txb: TransactionBlock, 7 | rateBps: bigint | TransactionArgument 8 | ) { 9 | return txb.moveCall({ 10 | target: `${PUBLISHED_AT}::flat_fee::new`, 11 | arguments: [ 12 | pure(txb, rateBps, `u64`) 13 | ], 14 | }) 15 | } 16 | 17 | export interface CalcFeeArgs { 18 | proceedsValue: bigint | TransactionArgument; rateBps: bigint | TransactionArgument 19 | } 20 | 21 | export function calcFee( 22 | txb: TransactionBlock, 23 | args: CalcFeeArgs 24 | ) { 25 | return txb.moveCall({ 26 | target: `${PUBLISHED_AT}::flat_fee::calc_fee`, 27 | arguments: [ 28 | pure(txb, args.proceedsValue, `u64`), pure(txb, args.rateBps, `u64`) 29 | ], 30 | }) 31 | } 32 | 33 | export interface CollectProceedsAndFeesArgs { 34 | marketplace: ObjectArg; listing: ObjectArg 35 | } 36 | 37 | export function collectProceedsAndFees( 38 | txb: TransactionBlock, 39 | typeArg: string, 40 | args: CollectProceedsAndFeesArgs 41 | ) { 42 | return txb.moveCall({ 43 | target: `${PUBLISHED_AT}::flat_fee::collect_proceeds_and_fees`, 44 | typeArguments: [typeArg], 45 | arguments: [ 46 | obj(txb, args.marketplace), obj(txb, args.listing) 47 | ], 48 | }) 49 | } 50 | 51 | export function initFee( 52 | txb: TransactionBlock, 53 | rate: bigint | TransactionArgument 54 | ) { 55 | return txb.moveCall({ 56 | target: `${PUBLISHED_AT}::flat_fee::init_fee`, 57 | arguments: [ 58 | pure(txb, rate, `u64`) 59 | ], 60 | }) 61 | } 62 | -------------------------------------------------------------------------------- /client/launchpad/frozen-pub/functions.ts: -------------------------------------------------------------------------------- 1 | import {PUBLISHED_AT} from ".."; 2 | import {ObjectArg, obj} from "../../_framework/util"; 3 | import {TransactionBlock} from "@mysten/sui.js/transactions"; 4 | 5 | export function init( 6 | txb: TransactionBlock, 7 | otw: ObjectArg 8 | ) { 9 | return txb.moveCall({ 10 | target: `${PUBLISHED_AT}::frozen_pub::init`, 11 | arguments: [ 12 | obj(txb, otw) 13 | ], 14 | }) 15 | } 16 | -------------------------------------------------------------------------------- /client/launchpad/index.ts: -------------------------------------------------------------------------------- 1 | export const PACKAGE_ID = "0xc74531639fadfb02d30f05f37de4cf1e1149ed8d23658edd089004830068180b"; 2 | export const PUBLISHED_AT = "0x546b50e2570a478ecdfc6e836077fc1f69306393738b0be2df459e658ed20915"; 3 | -------------------------------------------------------------------------------- /client/launchpad/init.ts: -------------------------------------------------------------------------------- 1 | import * as dutchAuction from "./dutch-auction/structs"; 2 | import * as englishAuction from "./english-auction/structs"; 3 | import * as fixedPrice from "./fixed-price/structs"; 4 | import * as flatFee from "./flat-fee/structs"; 5 | import * as frozenPub from "./frozen-pub/structs"; 6 | import * as inventory from "./inventory/structs"; 7 | import * as launchpad from "./launchpad/structs"; 8 | import * as limitedFixedPrice from "./limited-fixed-price/structs"; 9 | import * as listing from "./listing/structs"; 10 | import * as marketWhitelist from "./market-whitelist/structs"; 11 | import * as marketplace from "./marketplace/structs"; 12 | import * as proceeds from "./proceeds/structs"; 13 | import * as rebate from "./rebate/structs"; 14 | import * as venue from "./venue/structs"; 15 | import * as warehouse from "./warehouse/structs"; 16 | import {StructClassLoader} from "../_framework/loader"; 17 | 18 | export function registerClasses(loader: StructClassLoader) { 19 | loader.register(proceeds.Proceeds); 20 | loader.register(proceeds.QtSold); 21 | loader.register(venue.Venue); 22 | loader.register(warehouse.RedeemCommitment); 23 | loader.register(warehouse.Warehouse); 24 | loader.register(rebate.Rebate); 25 | loader.register(rebate.RebateDfKey); 26 | loader.register(marketplace.Marketplace); 27 | loader.register(marketplace.MembersDfKey); 28 | loader.register(marketplace.PermissionlessFlag); 29 | loader.register(inventory.Inventory); 30 | loader.register(inventory.WarehouseKey); 31 | loader.register(listing.Listing); 32 | loader.register(listing.MembersDfKey); 33 | loader.register(listing.CreateListingEvent); 34 | loader.register(listing.DeleteListingEvent); 35 | loader.register(listing.NftSoldEvent); 36 | loader.register(listing.RequestToJoin); 37 | loader.register(listing.RequestToJoinDfKey); 38 | loader.register(listing.StartSaleDfKey); 39 | loader.register(listing.WhitelistDfKey); 40 | loader.register(marketWhitelist.Certificate); 41 | loader.register(marketWhitelist.Whitelist); 42 | loader.register(dutchAuction.Bid); 43 | loader.register(dutchAuction.MarketKey); 44 | loader.register(dutchAuction.DutchAuctionMarket); 45 | loader.register(englishAuction.Bid); 46 | loader.register(englishAuction.MarketKey); 47 | loader.register(englishAuction.EnglishAuction); 48 | loader.register(fixedPrice.MarketKey); 49 | loader.register(fixedPrice.FixedPriceMarket); 50 | loader.register(flatFee.FlatFee); 51 | loader.register(frozenPub.FROZEN_PUB); 52 | loader.register(launchpad.LAUNCHPAD); 53 | loader.register(limitedFixedPrice.MarketKey); 54 | loader.register(limitedFixedPrice.LimitedFixedPriceMarket); 55 | } 56 | -------------------------------------------------------------------------------- /client/launchpad/launchpad/functions.ts: -------------------------------------------------------------------------------- 1 | import {PUBLISHED_AT} from ".."; 2 | import {ObjectArg, obj} from "../../_framework/util"; 3 | import {TransactionBlock} from "@mysten/sui.js/transactions"; 4 | 5 | export function init( 6 | txb: TransactionBlock, 7 | otw: ObjectArg 8 | ) { 9 | return txb.moveCall({ 10 | target: `${PUBLISHED_AT}::launchpad::init`, 11 | arguments: [ 12 | obj(txb, otw) 13 | ], 14 | }) 15 | } 16 | -------------------------------------------------------------------------------- /client/liquidity-layer-v-1/frozen-pub/functions.ts: -------------------------------------------------------------------------------- 1 | import {PUBLISHED_AT} from ".."; 2 | import {ObjectArg, obj} from "../../_framework/util"; 3 | import {TransactionBlock} from "@mysten/sui.js/transactions"; 4 | 5 | export function init( 6 | txb: TransactionBlock, 7 | otw: ObjectArg 8 | ) { 9 | return txb.moveCall({ 10 | target: `${PUBLISHED_AT}::frozen_pub::init`, 11 | arguments: [ 12 | obj(txb, otw) 13 | ], 14 | }) 15 | } 16 | -------------------------------------------------------------------------------- /client/liquidity-layer-v-1/index.ts: -------------------------------------------------------------------------------- 1 | export const PACKAGE_ID = "0x4e0629fa51a62b0c1d7c7b9fc89237ec5b6f630d7798ad3f06d820afb93a995a"; 2 | export const PUBLISHED_AT = "0x8534e4cdfd28709c94330a9783c3d5fe6f5daba0bffb69102ce303c5b38aed5a"; 3 | -------------------------------------------------------------------------------- /client/liquidity-layer-v-1/init.ts: -------------------------------------------------------------------------------- 1 | import * as bidding from "./bidding/structs"; 2 | import * as frozenPub from "./frozen-pub/structs"; 3 | import * as liquidityLayer from "./liquidity-layer/structs"; 4 | import * as orderbook from "./orderbook/structs"; 5 | import * as trading from "./trading/structs"; 6 | import {StructClassLoader} from "../_framework/loader"; 7 | 8 | export function registerClasses(loader: StructClassLoader) { 9 | loader.register(trading.AskCommission); 10 | loader.register(trading.BidCommission); 11 | loader.register(bidding.Witness); 12 | loader.register(bidding.Bid); 13 | loader.register(bidding.BidClosedEvent); 14 | loader.register(bidding.BidCreatedEvent); 15 | loader.register(bidding.BidMatchedEvent); 16 | loader.register(frozenPub.FROZEN_PUB); 17 | loader.register(liquidityLayer.LIQUIDITY_LAYER); 18 | loader.register(orderbook.Witness); 19 | loader.register(orderbook.Bid); 20 | loader.register(orderbook.BidClosedEvent); 21 | loader.register(orderbook.BidCreatedEvent); 22 | loader.register(orderbook.AdministratorsDfKey); 23 | loader.register(orderbook.Ask); 24 | loader.register(orderbook.AskClosedEvent); 25 | loader.register(orderbook.AskCreatedEvent); 26 | loader.register(orderbook.IsDeprecatedDfKey); 27 | loader.register(orderbook.Orderbook); 28 | loader.register(orderbook.OrderbookCreatedEvent); 29 | loader.register(orderbook.TimeLockDfKey); 30 | loader.register(orderbook.TradeFilledEvent); 31 | loader.register(orderbook.TradeInfo); 32 | loader.register(orderbook.TradeIntermediate); 33 | loader.register(orderbook.TradeIntermediateDfKey); 34 | loader.register(orderbook.UnderMigrationToDfKey); 35 | loader.register(orderbook.WitnessProtectedActions); 36 | } 37 | -------------------------------------------------------------------------------- /client/liquidity-layer-v-1/liquidity-layer/functions.ts: -------------------------------------------------------------------------------- 1 | import {PUBLISHED_AT} from ".."; 2 | import {ObjectArg, obj} from "../../_framework/util"; 3 | import {TransactionBlock} from "@mysten/sui.js/transactions"; 4 | 5 | export function init( 6 | txb: TransactionBlock, 7 | otw: ObjectArg 8 | ) { 9 | return txb.moveCall({ 10 | target: `${PUBLISHED_AT}::liquidity_layer::init`, 11 | arguments: [ 12 | obj(txb, otw) 13 | ], 14 | }) 15 | } 16 | -------------------------------------------------------------------------------- /client/nft-protocol/frozen-pub/functions.ts: -------------------------------------------------------------------------------- 1 | import {PUBLISHED_AT} from ".."; 2 | import {ObjectArg, obj} from "../../_framework/util"; 3 | import {TransactionBlock} from "@mysten/sui.js/transactions"; 4 | 5 | export function init( 6 | txb: TransactionBlock, 7 | otw: ObjectArg 8 | ) { 9 | return txb.moveCall({ 10 | target: `${PUBLISHED_AT}::frozen_pub::init`, 11 | arguments: [ 12 | obj(txb, otw) 13 | ], 14 | }) 15 | } 16 | -------------------------------------------------------------------------------- /client/nft-protocol/index.ts: -------------------------------------------------------------------------------- 1 | export const PACKAGE_ID = "0xbc3df36be17f27ac98e3c839b2589db8475fa07b20657b08e8891e3aaf5ee5f9"; 2 | export const PUBLISHED_AT = "0x6f42ec2355fcda5ebeee2399d901ae9f71cb214e640a45a0007f1f1cdf9f7b5e"; 3 | -------------------------------------------------------------------------------- /client/nft-protocol/mint-event/functions.ts: -------------------------------------------------------------------------------- 1 | import {PUBLISHED_AT} from ".."; 2 | import {GenericArg, ObjectArg, generic, obj, pure} from "../../_framework/util"; 3 | import {TransactionArgument, TransactionBlock} from "@mysten/sui.js/transactions"; 4 | 5 | export interface EmitBurnArgs { 6 | guard: ObjectArg; collectionId: string | TransactionArgument; object: ObjectArg 7 | } 8 | 9 | export function emitBurn( 10 | txb: TransactionBlock, 11 | typeArg: string, 12 | args: EmitBurnArgs 13 | ) { 14 | return txb.moveCall({ 15 | target: `${PUBLISHED_AT}::mint_event::emit_burn`, 16 | typeArguments: [typeArg], 17 | arguments: [ 18 | obj(txb, args.guard), pure(txb, args.collectionId, `0x2::object::ID`), obj(txb, args.object) 19 | ], 20 | }) 21 | } 22 | 23 | export interface EmitMintArgs { 24 | witness: ObjectArg; collectionId: string | TransactionArgument; object: GenericArg 25 | } 26 | 27 | export function emitMint( 28 | txb: TransactionBlock, 29 | typeArg: string, 30 | args: EmitMintArgs 31 | ) { 32 | return txb.moveCall({ 33 | target: `${PUBLISHED_AT}::mint_event::emit_mint`, 34 | typeArguments: [typeArg], 35 | arguments: [ 36 | obj(txb, args.witness), pure(txb, args.collectionId, `0x2::object::ID`), generic(txb, `${typeArg}`, args.object) 37 | ], 38 | }) 39 | } 40 | 41 | export interface StartBurnArgs { 42 | witness: ObjectArg; object: GenericArg 43 | } 44 | 45 | export function startBurn( 46 | txb: TransactionBlock, 47 | typeArg: string, 48 | args: StartBurnArgs 49 | ) { 50 | return txb.moveCall({ 51 | target: `${PUBLISHED_AT}::mint_event::start_burn`, 52 | typeArguments: [typeArg], 53 | arguments: [ 54 | obj(txb, args.witness), generic(txb, `${typeArg}`, args.object) 55 | ], 56 | }) 57 | } 58 | -------------------------------------------------------------------------------- /client/nft-protocol/nft-protocol/functions.ts: -------------------------------------------------------------------------------- 1 | import {PUBLISHED_AT} from ".."; 2 | import {ObjectArg, obj} from "../../_framework/util"; 3 | import {TransactionBlock} from "@mysten/sui.js/transactions"; 4 | 5 | export function init( 6 | txb: TransactionBlock, 7 | otw: ObjectArg 8 | ) { 9 | return txb.moveCall({ 10 | target: `${PUBLISHED_AT}::nft_protocol::init`, 11 | arguments: [ 12 | obj(txb, otw) 13 | ], 14 | }) 15 | } 16 | 17 | export function initAuthlist( 18 | txb: TransactionBlock, 19 | ) { 20 | return txb.moveCall({ 21 | target: `${PUBLISHED_AT}::nft_protocol::init_authlist`, 22 | arguments: [], 23 | }) 24 | } 25 | 26 | export function initAllowlist( 27 | txb: TransactionBlock, 28 | ) { 29 | return txb.moveCall({ 30 | target: `${PUBLISHED_AT}::nft_protocol::init_allowlist`, 31 | arguments: [], 32 | }) 33 | } 34 | 35 | export function permissionlessPrivateKey( 36 | txb: TransactionBlock, 37 | ) { 38 | return txb.moveCall({ 39 | target: `${PUBLISHED_AT}::nft_protocol::permissionless_private_key`, 40 | arguments: [], 41 | }) 42 | } 43 | 44 | export function permissionlessPublicKey( 45 | txb: TransactionBlock, 46 | ) { 47 | return txb.moveCall({ 48 | target: `${PUBLISHED_AT}::nft_protocol::permissionless_public_key`, 49 | arguments: [], 50 | }) 51 | } 52 | -------------------------------------------------------------------------------- /client/nft-protocol/tags/functions.ts: -------------------------------------------------------------------------------- 1 | import {PUBLISHED_AT} from ".."; 2 | import {TransactionBlock} from "@mysten/sui.js/transactions"; 3 | 4 | export function symbol( 5 | txb: TransactionBlock, 6 | ) { 7 | return txb.moveCall({ 8 | target: `${PUBLISHED_AT}::tags::symbol`, 9 | arguments: [], 10 | }) 11 | } 12 | 13 | export function ticket( 14 | txb: TransactionBlock, 15 | ) { 16 | return txb.moveCall({ 17 | target: `${PUBLISHED_AT}::tags::ticket`, 18 | arguments: [], 19 | }) 20 | } 21 | 22 | export function art( 23 | txb: TransactionBlock, 24 | ) { 25 | return txb.moveCall({ 26 | target: `${PUBLISHED_AT}::tags::art`, 27 | arguments: [], 28 | }) 29 | } 30 | 31 | export function collectible( 32 | txb: TransactionBlock, 33 | ) { 34 | return txb.moveCall({ 35 | target: `${PUBLISHED_AT}::tags::collectible`, 36 | arguments: [], 37 | }) 38 | } 39 | 40 | export function domainName( 41 | txb: TransactionBlock, 42 | ) { 43 | return txb.moveCall({ 44 | target: `${PUBLISHED_AT}::tags::domain_name`, 45 | arguments: [], 46 | }) 47 | } 48 | 49 | export function gameAsset( 50 | txb: TransactionBlock, 51 | ) { 52 | return txb.moveCall({ 53 | target: `${PUBLISHED_AT}::tags::game_asset`, 54 | arguments: [], 55 | }) 56 | } 57 | 58 | export function license( 59 | txb: TransactionBlock, 60 | ) { 61 | return txb.moveCall({ 62 | target: `${PUBLISHED_AT}::tags::license`, 63 | arguments: [], 64 | }) 65 | } 66 | 67 | export function music( 68 | txb: TransactionBlock, 69 | ) { 70 | return txb.moveCall({ 71 | target: `${PUBLISHED_AT}::tags::music`, 72 | arguments: [], 73 | }) 74 | } 75 | 76 | export function profilePicture( 77 | txb: TransactionBlock, 78 | ) { 79 | return txb.moveCall({ 80 | target: `${PUBLISHED_AT}::tags::profile_picture`, 81 | arguments: [], 82 | }) 83 | } 84 | 85 | export function tokenisedAsset( 86 | txb: TransactionBlock, 87 | ) { 88 | return txb.moveCall({ 89 | target: `${PUBLISHED_AT}::tags::tokenised_asset`, 90 | arguments: [], 91 | }) 92 | } 93 | 94 | export function video( 95 | txb: TransactionBlock, 96 | ) { 97 | return txb.moveCall({ 98 | target: `${PUBLISHED_AT}::tags::video`, 99 | arguments: [], 100 | }) 101 | } 102 | -------------------------------------------------------------------------------- /client/nft-protocol/transfer-allowlist/functions.ts: -------------------------------------------------------------------------------- 1 | import {PUBLISHED_AT} from ".."; 2 | import {ObjectArg, obj} from "../../_framework/util"; 3 | import {TransactionBlock} from "@mysten/sui.js/transactions"; 4 | 5 | export interface DropArgs { 6 | policy: ObjectArg; cap: ObjectArg 7 | } 8 | 9 | export function drop( 10 | txb: TransactionBlock, 11 | typeArg: string, 12 | args: DropArgs 13 | ) { 14 | return txb.moveCall({ 15 | target: `${PUBLISHED_AT}::transfer_allowlist::drop`, 16 | typeArguments: [typeArg], 17 | arguments: [ 18 | obj(txb, args.policy), obj(txb, args.cap) 19 | ], 20 | }) 21 | } 22 | 23 | export interface EnforceArgs { 24 | policy: ObjectArg; cap: ObjectArg 25 | } 26 | 27 | export function enforce( 28 | txb: TransactionBlock, 29 | typeArg: string, 30 | args: EnforceArgs 31 | ) { 32 | return txb.moveCall({ 33 | target: `${PUBLISHED_AT}::transfer_allowlist::enforce`, 34 | typeArguments: [typeArg], 35 | arguments: [ 36 | obj(txb, args.policy), obj(txb, args.cap) 37 | ], 38 | }) 39 | } 40 | 41 | export interface ConfirmTransfer_Args { 42 | self: ObjectArg; req: ObjectArg 43 | } 44 | 45 | export function confirmTransfer_( 46 | txb: TransactionBlock, 47 | typeArgs: [string, string], 48 | args: ConfirmTransfer_Args 49 | ) { 50 | return txb.moveCall({ 51 | target: `${PUBLISHED_AT}::transfer_allowlist::confirm_transfer_`, 52 | typeArguments: typeArgs, 53 | arguments: [ 54 | obj(txb, args.self), obj(txb, args.req) 55 | ], 56 | }) 57 | } 58 | 59 | export interface Drop_Args { 60 | policy: ObjectArg; cap: ObjectArg 61 | } 62 | 63 | export function drop_( 64 | txb: TransactionBlock, 65 | typeArgs: [string, string], 66 | args: Drop_Args 67 | ) { 68 | return txb.moveCall({ 69 | target: `${PUBLISHED_AT}::transfer_allowlist::drop_`, 70 | typeArguments: typeArgs, 71 | arguments: [ 72 | obj(txb, args.policy), obj(txb, args.cap) 73 | ], 74 | }) 75 | } 76 | 77 | export interface Enforce_Args { 78 | policy: ObjectArg; cap: ObjectArg 79 | } 80 | 81 | export function enforce_( 82 | txb: TransactionBlock, 83 | typeArgs: [string, string], 84 | args: Enforce_Args 85 | ) { 86 | return txb.moveCall({ 87 | target: `${PUBLISHED_AT}::transfer_allowlist::enforce_`, 88 | typeArguments: typeArgs, 89 | arguments: [ 90 | obj(txb, args.policy), obj(txb, args.cap) 91 | ], 92 | }) 93 | } 94 | 95 | export interface ConfirmTransferArgs { 96 | self: ObjectArg; req: ObjectArg 97 | } 98 | 99 | export function confirmTransfer( 100 | txb: TransactionBlock, 101 | typeArg: string, 102 | args: ConfirmTransferArgs 103 | ) { 104 | return txb.moveCall({ 105 | target: `${PUBLISHED_AT}::transfer_allowlist::confirm_transfer`, 106 | typeArguments: [typeArg], 107 | arguments: [ 108 | obj(txb, args.self), obj(txb, args.req) 109 | ], 110 | }) 111 | } 112 | -------------------------------------------------------------------------------- /client/nft-protocol/transfer-token/functions.ts: -------------------------------------------------------------------------------- 1 | import {PUBLISHED_AT} from ".."; 2 | import {GenericArg, ObjectArg, generic, obj, pure} from "../../_framework/util"; 3 | import {TransactionArgument, TransactionBlock} from "@mysten/sui.js/transactions"; 4 | 5 | export interface NewArgs { 6 | witness: ObjectArg; futureRecipient: string | TransactionArgument 7 | } 8 | 9 | export function new_( 10 | txb: TransactionBlock, 11 | typeArg: string, 12 | args: NewArgs 13 | ) { 14 | return txb.moveCall({ 15 | target: `${PUBLISHED_AT}::transfer_token::new`, 16 | typeArguments: [typeArg], 17 | arguments: [ 18 | obj(txb, args.witness), pure(txb, args.futureRecipient, `address`) 19 | ], 20 | }) 21 | } 22 | 23 | export interface DropArgs { 24 | policy: ObjectArg; cap: ObjectArg 25 | } 26 | 27 | export function drop( 28 | txb: TransactionBlock, 29 | typeArgs: [string, string], 30 | args: DropArgs 31 | ) { 32 | return txb.moveCall({ 33 | target: `${PUBLISHED_AT}::transfer_token::drop`, 34 | typeArguments: typeArgs, 35 | arguments: [ 36 | obj(txb, args.policy), obj(txb, args.cap) 37 | ], 38 | }) 39 | } 40 | 41 | export interface ConfirmArgs { 42 | nft: GenericArg; token: ObjectArg; req: ObjectArg 43 | } 44 | 45 | export function confirm( 46 | txb: TransactionBlock, 47 | typeArgs: [string, string], 48 | args: ConfirmArgs 49 | ) { 50 | return txb.moveCall({ 51 | target: `${PUBLISHED_AT}::transfer_token::confirm`, 52 | typeArguments: typeArgs, 53 | arguments: [ 54 | generic(txb, `${typeArgs[0]}`, args.nft), obj(txb, args.token), obj(txb, args.req) 55 | ], 56 | }) 57 | } 58 | 59 | export interface EnforceArgs { 60 | policy: ObjectArg; cap: ObjectArg 61 | } 62 | 63 | export function enforce( 64 | txb: TransactionBlock, 65 | typeArgs: [string, string], 66 | args: EnforceArgs 67 | ) { 68 | return txb.moveCall({ 69 | target: `${PUBLISHED_AT}::transfer_token::enforce`, 70 | typeArguments: typeArgs, 71 | arguments: [ 72 | obj(txb, args.policy), obj(txb, args.cap) 73 | ], 74 | }) 75 | } 76 | 77 | export interface CreateAndTransferArgs { 78 | witness: ObjectArg; receiver: string | TransactionArgument; currentOwner: string | TransactionArgument 79 | } 80 | 81 | export function createAndTransfer( 82 | txb: TransactionBlock, 83 | typeArg: string, 84 | args: CreateAndTransferArgs 85 | ) { 86 | return txb.moveCall({ 87 | target: `${PUBLISHED_AT}::transfer_token::create_and_transfer`, 88 | typeArguments: [typeArg], 89 | arguments: [ 90 | obj(txb, args.witness), pure(txb, args.receiver, `address`), pure(txb, args.currentOwner, `address`) 91 | ], 92 | }) 93 | } 94 | -------------------------------------------------------------------------------- /client/nft-protocol/url/functions.ts: -------------------------------------------------------------------------------- 1 | import {PUBLISHED_AT} from ".."; 2 | import {ObjectArg, obj} from "../../_framework/util"; 3 | import {TransactionBlock} from "@mysten/sui.js/transactions"; 4 | 5 | export interface AddDomainArgs { 6 | nft: ObjectArg; domain: ObjectArg 7 | } 8 | 9 | export function addDomain( 10 | txb: TransactionBlock, 11 | args: AddDomainArgs 12 | ) { 13 | return txb.moveCall({ 14 | target: `${PUBLISHED_AT}::url::add_domain`, 15 | arguments: [ 16 | obj(txb, args.nft), obj(txb, args.domain) 17 | ], 18 | }) 19 | } 20 | 21 | export function borrowDomain( 22 | txb: TransactionBlock, 23 | nft: ObjectArg 24 | ) { 25 | return txb.moveCall({ 26 | target: `${PUBLISHED_AT}::url::borrow_domain`, 27 | arguments: [ 28 | obj(txb, nft) 29 | ], 30 | }) 31 | } 32 | 33 | export function borrowDomainMut( 34 | txb: TransactionBlock, 35 | nft: ObjectArg 36 | ) { 37 | return txb.moveCall({ 38 | target: `${PUBLISHED_AT}::url::borrow_domain_mut`, 39 | arguments: [ 40 | obj(txb, nft) 41 | ], 42 | }) 43 | } 44 | 45 | export function hasDomain( 46 | txb: TransactionBlock, 47 | nft: ObjectArg 48 | ) { 49 | return txb.moveCall({ 50 | target: `${PUBLISHED_AT}::url::has_domain`, 51 | arguments: [ 52 | obj(txb, nft) 53 | ], 54 | }) 55 | } 56 | 57 | export function removeDomain( 58 | txb: TransactionBlock, 59 | nft: ObjectArg 60 | ) { 61 | return txb.moveCall({ 62 | target: `${PUBLISHED_AT}::url::remove_domain`, 63 | arguments: [ 64 | obj(txb, nft) 65 | ], 66 | }) 67 | } 68 | 69 | export function assertNoUrl( 70 | txb: TransactionBlock, 71 | nft: ObjectArg 72 | ) { 73 | return txb.moveCall({ 74 | target: `${PUBLISHED_AT}::url::assert_no_url`, 75 | arguments: [ 76 | obj(txb, nft) 77 | ], 78 | }) 79 | } 80 | 81 | export function assertUrl( 82 | txb: TransactionBlock, 83 | nft: ObjectArg 84 | ) { 85 | return txb.moveCall({ 86 | target: `${PUBLISHED_AT}::url::assert_url`, 87 | arguments: [ 88 | obj(txb, nft) 89 | ], 90 | }) 91 | } 92 | -------------------------------------------------------------------------------- /client/originmate/bloom-filter/functions.ts: -------------------------------------------------------------------------------- 1 | import {PUBLISHED_AT} from ".."; 2 | import {ObjectArg, obj, pure} from "../../_framework/util"; 3 | import {TransactionArgument, TransactionBlock} from "@mysten/sui.js/transactions"; 4 | 5 | export interface AddArgs { 6 | filter: ObjectArg; item: Array | TransactionArgument 7 | } 8 | 9 | export function add( 10 | txb: TransactionBlock, 11 | args: AddArgs 12 | ) { 13 | return txb.moveCall({ 14 | target: `${PUBLISHED_AT}::bloom_filter::add`, 15 | arguments: [ 16 | obj(txb, args.filter), pure(txb, args.item, `vector`) 17 | ], 18 | }) 19 | } 20 | 21 | export function new_( 22 | txb: TransactionBlock, 23 | itemNum: bigint | TransactionArgument 24 | ) { 25 | return txb.moveCall({ 26 | target: `${PUBLISHED_AT}::bloom_filter::new`, 27 | arguments: [ 28 | pure(txb, itemNum, `u64`) 29 | ], 30 | }) 31 | } 32 | 33 | export interface AddToBitmapArgs { 34 | bitmap: bigint | TransactionArgument; hashCount: number | TransactionArgument; item: Array | TransactionArgument 35 | } 36 | 37 | export function addToBitmap( 38 | txb: TransactionBlock, 39 | args: AddToBitmapArgs 40 | ) { 41 | return txb.moveCall({ 42 | target: `${PUBLISHED_AT}::bloom_filter::add_to_bitmap`, 43 | arguments: [ 44 | pure(txb, args.bitmap, `u256`), pure(txb, args.hashCount, `u8`), pure(txb, args.item, `vector`) 45 | ], 46 | }) 47 | } 48 | 49 | export interface CheckArgs { 50 | filter: ObjectArg; item: Array | TransactionArgument 51 | } 52 | 53 | export function check( 54 | txb: TransactionBlock, 55 | args: CheckArgs 56 | ) { 57 | return txb.moveCall({ 58 | target: `${PUBLISHED_AT}::bloom_filter::check`, 59 | arguments: [ 60 | obj(txb, args.filter), pure(txb, args.item, `vector`) 61 | ], 62 | }) 63 | } 64 | 65 | export interface FalsePositiveArgs { 66 | bitmap: bigint | TransactionArgument; hashCount: number | TransactionArgument; item: Array | TransactionArgument 67 | } 68 | 69 | export function falsePositive( 70 | txb: TransactionBlock, 71 | args: FalsePositiveArgs 72 | ) { 73 | return txb.moveCall({ 74 | target: `${PUBLISHED_AT}::bloom_filter::false_positive`, 75 | arguments: [ 76 | pure(txb, args.bitmap, `u256`), pure(txb, args.hashCount, `u8`), pure(txb, args.item, `vector`) 77 | ], 78 | }) 79 | } 80 | 81 | export function getHashCount( 82 | txb: TransactionBlock, 83 | itemNum: bigint | TransactionArgument 84 | ) { 85 | return txb.moveCall({ 86 | target: `${PUBLISHED_AT}::bloom_filter::get_hash_count`, 87 | arguments: [ 88 | pure(txb, itemNum, `u64`) 89 | ], 90 | }) 91 | } 92 | -------------------------------------------------------------------------------- /client/originmate/box/functions.ts: -------------------------------------------------------------------------------- 1 | import {PUBLISHED_AT} from ".."; 2 | import {GenericArg, ObjectArg, generic, obj, pure} from "../../_framework/util"; 3 | import {TransactionArgument, TransactionBlock} from "@mysten/sui.js/transactions"; 4 | 5 | export interface BoxArgs { 6 | recipient: string | TransactionArgument; objIn: GenericArg 7 | } 8 | 9 | export function box( 10 | txb: TransactionBlock, 11 | typeArg: string, 12 | args: BoxArgs 13 | ) { 14 | return txb.moveCall({ 15 | target: `${PUBLISHED_AT}::box::box`, 16 | typeArguments: [typeArg], 17 | arguments: [ 18 | pure(txb, args.recipient, `address`), generic(txb, `${typeArg}`, args.objIn) 19 | ], 20 | }) 21 | } 22 | 23 | export function unbox( 24 | txb: TransactionBlock, 25 | typeArg: string, 26 | box: ObjectArg 27 | ) { 28 | return txb.moveCall({ 29 | target: `${PUBLISHED_AT}::box::unbox`, 30 | typeArguments: [typeArg], 31 | arguments: [ 32 | obj(txb, box) 33 | ], 34 | }) 35 | } 36 | -------------------------------------------------------------------------------- /client/originmate/escrow-shared/functions.ts: -------------------------------------------------------------------------------- 1 | import {PUBLISHED_AT} from ".."; 2 | import {GenericArg, ObjectArg, generic, obj, pure} from "../../_framework/util"; 3 | import {TransactionArgument, TransactionBlock} from "@mysten/sui.js/transactions"; 4 | 5 | export function transfer( 6 | txb: TransactionBlock, 7 | typeArg: string, 8 | escrow: ObjectArg 9 | ) { 10 | return txb.moveCall({ 11 | target: `${PUBLISHED_AT}::escrow_shared::transfer`, 12 | typeArguments: [typeArg], 13 | arguments: [ 14 | obj(txb, escrow) 15 | ], 16 | }) 17 | } 18 | 19 | export interface EscrowArgs { 20 | sender: string | TransactionArgument; recipient: string | TransactionArgument; arbitrator: (string | TransactionArgument | TransactionArgument | null); objIn: GenericArg 21 | } 22 | 23 | export function escrow( 24 | txb: TransactionBlock, 25 | typeArg: string, 26 | args: EscrowArgs 27 | ) { 28 | return txb.moveCall({ 29 | target: `${PUBLISHED_AT}::escrow_shared::escrow`, 30 | typeArguments: [typeArg], 31 | arguments: [ 32 | pure(txb, args.sender, `address`), pure(txb, args.recipient, `address`), pure(txb, args.arbitrator, `0x1::option::Option
`), generic(txb, `${typeArg}`, args.objIn) 33 | ], 34 | }) 35 | } 36 | 37 | export function refund( 38 | txb: TransactionBlock, 39 | typeArg: string, 40 | escrow: ObjectArg 41 | ) { 42 | return txb.moveCall({ 43 | target: `${PUBLISHED_AT}::escrow_shared::refund`, 44 | typeArguments: [typeArg], 45 | arguments: [ 46 | obj(txb, escrow) 47 | ], 48 | }) 49 | } 50 | 51 | export function refundArbitrated( 52 | txb: TransactionBlock, 53 | typeArg: string, 54 | escrow: ObjectArg 55 | ) { 56 | return txb.moveCall({ 57 | target: `${PUBLISHED_AT}::escrow_shared::refund_arbitrated`, 58 | typeArguments: [typeArg], 59 | arguments: [ 60 | obj(txb, escrow) 61 | ], 62 | }) 63 | } 64 | 65 | export function transferArbitrated( 66 | txb: TransactionBlock, 67 | typeArg: string, 68 | escrow: ObjectArg 69 | ) { 70 | return txb.moveCall({ 71 | target: `${PUBLISHED_AT}::escrow_shared::transfer_arbitrated`, 72 | typeArguments: [typeArg], 73 | arguments: [ 74 | obj(txb, escrow) 75 | ], 76 | }) 77 | } 78 | -------------------------------------------------------------------------------- /client/originmate/escrow/functions.ts: -------------------------------------------------------------------------------- 1 | import {PUBLISHED_AT} from ".."; 2 | import {GenericArg, ObjectArg, generic, obj, pure} from "../../_framework/util"; 3 | import {TransactionArgument, TransactionBlock} from "@mysten/sui.js/transactions"; 4 | 5 | export function transfer( 6 | txb: TransactionBlock, 7 | typeArg: string, 8 | escrow: ObjectArg 9 | ) { 10 | return txb.moveCall({ 11 | target: `${PUBLISHED_AT}::escrow::transfer`, 12 | typeArguments: [typeArg], 13 | arguments: [ 14 | obj(txb, escrow) 15 | ], 16 | }) 17 | } 18 | 19 | export interface EscrowArgs { 20 | sender: string | TransactionArgument; recipient: string | TransactionArgument; objIn: GenericArg 21 | } 22 | 23 | export function escrow( 24 | txb: TransactionBlock, 25 | typeArg: string, 26 | args: EscrowArgs 27 | ) { 28 | return txb.moveCall({ 29 | target: `${PUBLISHED_AT}::escrow::escrow`, 30 | typeArguments: [typeArg], 31 | arguments: [ 32 | pure(txb, args.sender, `address`), pure(txb, args.recipient, `address`), generic(txb, `${typeArg}`, args.objIn) 33 | ], 34 | }) 35 | } 36 | -------------------------------------------------------------------------------- /client/originmate/index.ts: -------------------------------------------------------------------------------- 1 | export const PACKAGE_ID = "0xed6c6fe0732be937f4379bc0b471f0f6bfbe0e8741968009e0f01e6de3d59f32"; 2 | export const PUBLISHED_AT = "0xf8343240d42fbefdb499f2c316f939aa168bf7b29ab63c31bf6c4bc0ba97fe0"; 3 | -------------------------------------------------------------------------------- /client/originmate/init.ts: -------------------------------------------------------------------------------- 1 | import * as balances from "./balances/structs"; 2 | import * as bloomFilter from "./bloom-filter/structs"; 3 | import * as box from "./box/structs"; 4 | import * as critBitU64 from "./crit-bit-u64/structs"; 5 | import * as critBit from "./crit-bit/structs"; 6 | import * as escrowShared from "./escrow-shared/structs"; 7 | import * as escrow from "./escrow/structs"; 8 | import * as i128Type from "./i128-type/structs"; 9 | import * as i64Type from "./i64-type/structs"; 10 | import * as linearVesting from "./linear-vesting/structs"; 11 | import * as objectBox from "./object-box/structs"; 12 | import * as objectVec from "./object-vec/structs"; 13 | import * as quadraticVesting from "./quadratic-vesting/structs"; 14 | import * as typedId from "./typed-id/structs"; 15 | import {StructClassLoader} from "../_framework/loader"; 16 | 17 | export function registerClasses(loader: StructClassLoader) { 18 | loader.register(i128Type.I128); 19 | loader.register(i64Type.I64); 20 | loader.register(critBitU64.CB); 21 | loader.register(critBitU64.I); 22 | loader.register(critBitU64.O); 23 | loader.register(balances.Balances); 24 | loader.register(typedId.TypedID); 25 | loader.register(objectBox.ObjectBox); 26 | loader.register(bloomFilter.Filter); 27 | loader.register(box.Box); 28 | loader.register(critBit.CB); 29 | loader.register(critBit.I); 30 | loader.register(critBit.O); 31 | loader.register(escrow.Escrow); 32 | loader.register(escrowShared.Escrow); 33 | loader.register(linearVesting.ClawbackCapability); 34 | loader.register(linearVesting.Wallet); 35 | loader.register(objectVec.ObjectVec); 36 | loader.register(quadraticVesting.ClawbackCapability); 37 | loader.register(quadraticVesting.Wallet); 38 | } 39 | -------------------------------------------------------------------------------- /client/originmate/math-safe-precise/functions.ts: -------------------------------------------------------------------------------- 1 | import {PUBLISHED_AT} from ".."; 2 | import {pure} from "../../_framework/util"; 3 | import {TransactionArgument, TransactionBlock} from "@mysten/sui.js/transactions"; 4 | 5 | export interface QuadraticArgs { 6 | x: bigint | TransactionArgument; a: bigint | TransactionArgument; b: bigint | TransactionArgument; c: bigint | TransactionArgument 7 | } 8 | 9 | export function quadratic( 10 | txb: TransactionBlock, 11 | args: QuadraticArgs 12 | ) { 13 | return txb.moveCall({ 14 | target: `${PUBLISHED_AT}::math_safe_precise::quadratic`, 15 | arguments: [ 16 | pure(txb, args.x, `u64`), pure(txb, args.a, `u64`), pure(txb, args.b, `u64`), pure(txb, args.c, `u64`) 17 | ], 18 | }) 19 | } 20 | 21 | export interface MulDivArgs { 22 | a: bigint | TransactionArgument; b: bigint | TransactionArgument; c: bigint | TransactionArgument 23 | } 24 | 25 | export function mulDiv( 26 | txb: TransactionBlock, 27 | args: MulDivArgs 28 | ) { 29 | return txb.moveCall({ 30 | target: `${PUBLISHED_AT}::math_safe_precise::mul_div`, 31 | arguments: [ 32 | pure(txb, args.a, `u64`), pure(txb, args.b, `u64`), pure(txb, args.c, `u64`) 33 | ], 34 | }) 35 | } 36 | -------------------------------------------------------------------------------- /client/originmate/object-box/functions.ts: -------------------------------------------------------------------------------- 1 | import {PUBLISHED_AT} from ".."; 2 | import {GenericArg, ObjectArg, generic, obj} from "../../_framework/util"; 3 | import {TransactionBlock} from "@mysten/sui.js/transactions"; 4 | 5 | export function borrow( 6 | txb: TransactionBlock, 7 | typeArg: string, 8 | ob: ObjectArg 9 | ) { 10 | return txb.moveCall({ 11 | target: `${PUBLISHED_AT}::object_box::borrow`, 12 | typeArguments: [typeArg], 13 | arguments: [ 14 | obj(txb, ob) 15 | ], 16 | }) 17 | } 18 | 19 | export function borrowMut( 20 | txb: TransactionBlock, 21 | typeArg: string, 22 | ob: ObjectArg 23 | ) { 24 | return txb.moveCall({ 25 | target: `${PUBLISHED_AT}::object_box::borrow_mut`, 26 | typeArguments: [typeArg], 27 | arguments: [ 28 | obj(txb, ob) 29 | ], 30 | }) 31 | } 32 | 33 | export function empty( 34 | txb: TransactionBlock, 35 | ) { 36 | return txb.moveCall({ 37 | target: `${PUBLISHED_AT}::object_box::empty`, 38 | arguments: [], 39 | }) 40 | } 41 | 42 | export function isEmpty( 43 | txb: TransactionBlock, 44 | ob: ObjectArg 45 | ) { 46 | return txb.moveCall({ 47 | target: `${PUBLISHED_AT}::object_box::is_empty`, 48 | arguments: [ 49 | obj(txb, ob) 50 | ], 51 | }) 52 | } 53 | 54 | export function remove( 55 | txb: TransactionBlock, 56 | typeArg: string, 57 | ob: ObjectArg 58 | ) { 59 | return txb.moveCall({ 60 | target: `${PUBLISHED_AT}::object_box::remove`, 61 | typeArguments: [typeArg], 62 | arguments: [ 63 | obj(txb, ob) 64 | ], 65 | }) 66 | } 67 | 68 | export interface AddArgs { 69 | ob: ObjectArg; v: GenericArg 70 | } 71 | 72 | export function add( 73 | txb: TransactionBlock, 74 | typeArg: string, 75 | args: AddArgs 76 | ) { 77 | return txb.moveCall({ 78 | target: `${PUBLISHED_AT}::object_box::add`, 79 | typeArguments: [typeArg], 80 | arguments: [ 81 | obj(txb, args.ob), generic(txb, `${typeArg}`, args.v) 82 | ], 83 | }) 84 | } 85 | 86 | export function new_( 87 | txb: TransactionBlock, 88 | typeArg: string, 89 | object: GenericArg 90 | ) { 91 | return txb.moveCall({ 92 | target: `${PUBLISHED_AT}::object_box::new`, 93 | typeArguments: [typeArg], 94 | arguments: [ 95 | generic(txb, `${typeArg}`, object) 96 | ], 97 | }) 98 | } 99 | 100 | export function hasObject( 101 | txb: TransactionBlock, 102 | typeArg: string, 103 | ob: ObjectArg 104 | ) { 105 | return txb.moveCall({ 106 | target: `${PUBLISHED_AT}::object_box::has_object`, 107 | typeArguments: [typeArg], 108 | arguments: [ 109 | obj(txb, ob) 110 | ], 111 | }) 112 | } 113 | -------------------------------------------------------------------------------- /client/originmate/to-string/functions.ts: -------------------------------------------------------------------------------- 1 | import {PUBLISHED_AT} from ".."; 2 | import {pure} from "../../_framework/util"; 3 | import {TransactionArgument, TransactionBlock} from "@mysten/sui.js/transactions"; 4 | 5 | export function toString( 6 | txb: TransactionBlock, 7 | value: bigint | TransactionArgument 8 | ) { 9 | return txb.moveCall({ 10 | target: `${PUBLISHED_AT}::to_string::to_string`, 11 | arguments: [ 12 | pure(txb, value, `u128`) 13 | ], 14 | }) 15 | } 16 | 17 | export function bytesToHexString( 18 | txb: TransactionBlock, 19 | bytes: Array | TransactionArgument 20 | ) { 21 | return txb.moveCall({ 22 | target: `${PUBLISHED_AT}::to_string::bytes_to_hex_string`, 23 | arguments: [ 24 | pure(txb, bytes, `vector`) 25 | ], 26 | }) 27 | } 28 | 29 | export function toHexString( 30 | txb: TransactionBlock, 31 | value: bigint | TransactionArgument 32 | ) { 33 | return txb.moveCall({ 34 | target: `${PUBLISHED_AT}::to_string::to_hex_string`, 35 | arguments: [ 36 | pure(txb, value, `u128`) 37 | ], 38 | }) 39 | } 40 | 41 | export interface ToHexStringFixedLengthArgs { 42 | value: bigint | TransactionArgument; length: bigint | TransactionArgument 43 | } 44 | 45 | export function toHexStringFixedLength( 46 | txb: TransactionBlock, 47 | args: ToHexStringFixedLengthArgs 48 | ) { 49 | return txb.moveCall({ 50 | target: `${PUBLISHED_AT}::to_string::to_hex_string_fixed_length`, 51 | arguments: [ 52 | pure(txb, args.value, `u128`), pure(txb, args.length, `u128`) 53 | ], 54 | }) 55 | } 56 | -------------------------------------------------------------------------------- /client/originmate/typed-id/functions.ts: -------------------------------------------------------------------------------- 1 | import {PUBLISHED_AT} from ".."; 2 | import {GenericArg, ObjectArg, generic, obj} from "../../_framework/util"; 3 | import {TransactionBlock} from "@mysten/sui.js/transactions"; 4 | 5 | export function new_( 6 | txb: TransactionBlock, 7 | typeArg: string, 8 | obj: GenericArg 9 | ) { 10 | return txb.moveCall({ 11 | target: `${PUBLISHED_AT}::typed_id::new`, 12 | typeArguments: [typeArg], 13 | arguments: [ 14 | generic(txb, `${typeArg}`, obj) 15 | ], 16 | }) 17 | } 18 | 19 | export function asId( 20 | txb: TransactionBlock, 21 | typeArg: string, 22 | typedId: ObjectArg 23 | ) { 24 | return txb.moveCall({ 25 | target: `${PUBLISHED_AT}::typed_id::as_id`, 26 | typeArguments: [typeArg], 27 | arguments: [ 28 | obj(txb, typedId) 29 | ], 30 | }) 31 | } 32 | 33 | export interface EqualsObjectArgs { 34 | typedId: ObjectArg; obj: GenericArg 35 | } 36 | 37 | export function equalsObject( 38 | txb: TransactionBlock, 39 | typeArg: string, 40 | args: EqualsObjectArgs 41 | ) { 42 | return txb.moveCall({ 43 | target: `${PUBLISHED_AT}::typed_id::equals_object`, 44 | typeArguments: [typeArg], 45 | arguments: [ 46 | obj(txb, args.typedId), generic(txb, `${typeArg}`, args.obj) 47 | ], 48 | }) 49 | } 50 | 51 | export function toId( 52 | txb: TransactionBlock, 53 | typeArg: string, 54 | typedId: ObjectArg 55 | ) { 56 | return txb.moveCall({ 57 | target: `${PUBLISHED_AT}::typed_id::to_id`, 58 | typeArguments: [typeArg], 59 | arguments: [ 60 | obj(txb, typedId) 61 | ], 62 | }) 63 | } 64 | -------------------------------------------------------------------------------- /client/permissions/frozen-pub/functions.ts: -------------------------------------------------------------------------------- 1 | import {PUBLISHED_AT} from ".."; 2 | import {ObjectArg, obj} from "../../_framework/util"; 3 | import {TransactionBlock} from "@mysten/sui.js/transactions"; 4 | 5 | export function init( 6 | txb: TransactionBlock, 7 | otw: ObjectArg 8 | ) { 9 | return txb.moveCall({ 10 | target: `${PUBLISHED_AT}::frozen_pub::init`, 11 | arguments: [ 12 | obj(txb, otw) 13 | ], 14 | }) 15 | } 16 | -------------------------------------------------------------------------------- /client/permissions/frozen-publisher/functions.ts: -------------------------------------------------------------------------------- 1 | import {PUBLISHED_AT} from ".."; 2 | import {GenericArg, ObjectArg, generic, obj} from "../../_framework/util"; 3 | import {TransactionBlock} from "@mysten/sui.js/transactions"; 4 | 5 | export function new_( 6 | txb: TransactionBlock, 7 | inner: ObjectArg 8 | ) { 9 | return txb.moveCall({ 10 | target: `${PUBLISHED_AT}::frozen_publisher::new`, 11 | arguments: [ 12 | obj(txb, inner) 13 | ], 14 | }) 15 | } 16 | 17 | export function publicFreezeObject( 18 | txb: TransactionBlock, 19 | self: ObjectArg 20 | ) { 21 | return txb.moveCall({ 22 | target: `${PUBLISHED_AT}::frozen_publisher::public_freeze_object`, 23 | arguments: [ 24 | obj(txb, self) 25 | ], 26 | }) 27 | } 28 | 29 | export interface BorrowPublisherArgs { 30 | witness: ObjectArg; self: ObjectArg 31 | } 32 | 33 | export function borrowPublisher( 34 | txb: TransactionBlock, 35 | typeArg: string, 36 | args: BorrowPublisherArgs 37 | ) { 38 | return txb.moveCall({ 39 | target: `${PUBLISHED_AT}::frozen_publisher::borrow_publisher`, 40 | typeArguments: [typeArg], 41 | arguments: [ 42 | obj(txb, args.witness), obj(txb, args.self) 43 | ], 44 | }) 45 | } 46 | 47 | export function freezeFromOtw( 48 | txb: TransactionBlock, 49 | typeArg: string, 50 | otw: GenericArg 51 | ) { 52 | return txb.moveCall({ 53 | target: `${PUBLISHED_AT}::frozen_publisher::freeze_from_otw`, 54 | typeArguments: [typeArg], 55 | arguments: [ 56 | generic(txb, `${typeArg}`, otw) 57 | ], 58 | }) 59 | } 60 | 61 | export function init( 62 | txb: TransactionBlock, 63 | otw: ObjectArg 64 | ) { 65 | return txb.moveCall({ 66 | target: `${PUBLISHED_AT}::frozen_publisher::init`, 67 | arguments: [ 68 | obj(txb, otw) 69 | ], 70 | }) 71 | } 72 | 73 | export function mod( 74 | txb: TransactionBlock, 75 | self: ObjectArg 76 | ) { 77 | return txb.moveCall({ 78 | target: `${PUBLISHED_AT}::frozen_publisher::mod`, 79 | arguments: [ 80 | obj(txb, self) 81 | ], 82 | }) 83 | } 84 | 85 | export interface NewDisplayArgs { 86 | parentWit: GenericArg; self: ObjectArg 87 | } 88 | 89 | export function newDisplay( 90 | txb: TransactionBlock, 91 | typeArgs: [string, string], 92 | args: NewDisplayArgs 93 | ) { 94 | return txb.moveCall({ 95 | target: `${PUBLISHED_AT}::frozen_publisher::new_display`, 96 | typeArguments: typeArgs, 97 | arguments: [ 98 | generic(txb, `${typeArgs[0]}`, args.parentWit), obj(txb, args.self) 99 | ], 100 | }) 101 | } 102 | 103 | export function pkg( 104 | txb: TransactionBlock, 105 | self: ObjectArg 106 | ) { 107 | return txb.moveCall({ 108 | target: `${PUBLISHED_AT}::frozen_publisher::pkg`, 109 | arguments: [ 110 | obj(txb, self) 111 | ], 112 | }) 113 | } 114 | -------------------------------------------------------------------------------- /client/permissions/index.ts: -------------------------------------------------------------------------------- 1 | export const PACKAGE_ID = "0x16c5f17f2d55584a6e6daa442ccf83b4530d10546a8e7dedda9ba324e012fc40"; 2 | export const PUBLISHED_AT = "0x59839eebd432e473ffca5a08675d26c49526ed39b584c39e762afa8c127f25a2"; 3 | -------------------------------------------------------------------------------- /client/permissions/init.ts: -------------------------------------------------------------------------------- 1 | import * as frozenPub from "./frozen-pub/structs"; 2 | import * as frozenPublisher from "./frozen-publisher/structs"; 3 | import * as permissions from "./permissions/structs"; 4 | import * as quorum from "./quorum/structs"; 5 | import * as witness from "./witness/structs"; 6 | import {StructClassLoader} from "../_framework/loader"; 7 | 8 | export function registerClasses(loader: StructClassLoader) { 9 | loader.register(witness.Witness); 10 | loader.register(witness.WitnessGenerator); 11 | loader.register(frozenPublisher.FROZEN_PUBLISHER); 12 | loader.register(frozenPublisher.FrozenPublisher); 13 | loader.register(frozenPub.FROZEN_PUB); 14 | loader.register(permissions.PERMISSIONS); 15 | loader.register(quorum.AddAdmin); 16 | loader.register(quorum.AddDelegate); 17 | loader.register(quorum.AdminField); 18 | loader.register(quorum.CreateQuorumEvent); 19 | loader.register(quorum.ExtensionToken); 20 | loader.register(quorum.Foo); 21 | loader.register(quorum.MemberField); 22 | loader.register(quorum.Quorum); 23 | loader.register(quorum.RemoveAdmin); 24 | loader.register(quorum.RemoveDelegate); 25 | loader.register(quorum.ReturnReceipt); 26 | loader.register(quorum.Signatures); 27 | } 28 | -------------------------------------------------------------------------------- /client/permissions/permissions/functions.ts: -------------------------------------------------------------------------------- 1 | import {PUBLISHED_AT} from ".."; 2 | import {ObjectArg, obj} from "../../_framework/util"; 3 | import {TransactionBlock} from "@mysten/sui.js/transactions"; 4 | 5 | export function init( 6 | txb: TransactionBlock, 7 | otw: ObjectArg 8 | ) { 9 | return txb.moveCall({ 10 | target: `${PUBLISHED_AT}::permissions::init`, 11 | arguments: [ 12 | obj(txb, otw) 13 | ], 14 | }) 15 | } 16 | -------------------------------------------------------------------------------- /client/permissions/witness/functions.ts: -------------------------------------------------------------------------------- 1 | import {PUBLISHED_AT} from ".."; 2 | import {GenericArg, ObjectArg, generic, obj} from "../../_framework/util"; 3 | import {TransactionBlock} from "@mysten/sui.js/transactions"; 4 | 5 | export function delegate( 6 | txb: TransactionBlock, 7 | typeArg: string, 8 | generator: ObjectArg 9 | ) { 10 | return txb.moveCall({ 11 | target: `${PUBLISHED_AT}::witness::delegate`, 12 | typeArguments: [typeArg], 13 | arguments: [ 14 | obj(txb, generator) 15 | ], 16 | }) 17 | } 18 | 19 | export function fromPublisher( 20 | txb: TransactionBlock, 21 | typeArg: string, 22 | publisher: ObjectArg 23 | ) { 24 | return txb.moveCall({ 25 | target: `${PUBLISHED_AT}::witness::from_publisher`, 26 | typeArguments: [typeArg], 27 | arguments: [ 28 | obj(txb, publisher) 29 | ], 30 | }) 31 | } 32 | 33 | export function fromWitness( 34 | txb: TransactionBlock, 35 | typeArgs: [string, string], 36 | witness: GenericArg 37 | ) { 38 | return txb.moveCall({ 39 | target: `${PUBLISHED_AT}::witness::from_witness`, 40 | typeArguments: typeArgs, 41 | arguments: [ 42 | generic(txb, `${typeArgs[1]}`, witness) 43 | ], 44 | }) 45 | } 46 | 47 | export function generator( 48 | txb: TransactionBlock, 49 | typeArgs: [string, string], 50 | witness: GenericArg 51 | ) { 52 | return txb.moveCall({ 53 | target: `${PUBLISHED_AT}::witness::generator`, 54 | typeArguments: typeArgs, 55 | arguments: [ 56 | generic(txb, `${typeArgs[1]}`, witness) 57 | ], 58 | }) 59 | } 60 | 61 | export function generatorDelegated( 62 | txb: TransactionBlock, 63 | typeArg: string, 64 | witness: ObjectArg 65 | ) { 66 | return txb.moveCall({ 67 | target: `${PUBLISHED_AT}::witness::generator_delegated`, 68 | typeArguments: [typeArg], 69 | arguments: [ 70 | obj(txb, witness) 71 | ], 72 | }) 73 | } 74 | -------------------------------------------------------------------------------- /client/pseudorandom/index.ts: -------------------------------------------------------------------------------- 1 | export const PACKAGE_ID = "0x9e5962d5183664be8a7762fbe94eee6e3457c0cc701750c94c17f7f8ac5a32fb"; 2 | export const PUBLISHED_AT = "0x9a586ae29d94788c0fc1db567b83f277c9f20af4e825374e127a331f2ae8231c"; 3 | -------------------------------------------------------------------------------- /client/pseudorandom/init.ts: -------------------------------------------------------------------------------- 1 | import * as pseudorandom from "./pseudorandom/structs"; 2 | import {StructClassLoader} from "../_framework/loader"; 3 | 4 | export function registerClasses(loader: StructClassLoader) { 5 | loader.register(pseudorandom.Counter); 6 | } 7 | -------------------------------------------------------------------------------- /client/request/frozen-pub/functions.ts: -------------------------------------------------------------------------------- 1 | import {PUBLISHED_AT} from ".."; 2 | import {ObjectArg, obj} from "../../_framework/util"; 3 | import {TransactionBlock} from "@mysten/sui.js/transactions"; 4 | 5 | export function init( 6 | txb: TransactionBlock, 7 | otw: ObjectArg 8 | ) { 9 | return txb.moveCall({ 10 | target: `${PUBLISHED_AT}::frozen_pub::init`, 11 | arguments: [ 12 | obj(txb, otw) 13 | ], 14 | }) 15 | } 16 | -------------------------------------------------------------------------------- /client/request/index.ts: -------------------------------------------------------------------------------- 1 | export const PACKAGE_ID = "0xe2c7a6843cb13d9549a9d2dc1c266b572ead0b4b9f090e7c3c46de2714102b43"; 2 | export const PUBLISHED_AT = "0xadf32ebafc587cc86e1e56e59f7b17c7e8cbeb3315193be63c6f73157d4e88b9"; 3 | -------------------------------------------------------------------------------- /client/request/init.ts: -------------------------------------------------------------------------------- 1 | import * as borrowRequest from "./borrow-request/structs"; 2 | import * as frozenPub from "./frozen-pub/structs"; 3 | import * as obRequest from "./ob-request/structs"; 4 | import * as request from "./request/structs"; 5 | import * as transferRequest from "./transfer-request/structs"; 6 | import * as withdrawRequest from "./withdraw-request/structs"; 7 | import {StructClassLoader} from "../_framework/loader"; 8 | 9 | export function registerClasses(loader: StructClassLoader) { 10 | loader.register(transferRequest.TransferRequest); 11 | loader.register(transferRequest.Witness); 12 | loader.register(transferRequest.BalanceAccessCap); 13 | loader.register(transferRequest.BalanceDfKey); 14 | loader.register(transferRequest.OBCustomRulesDfKey); 15 | loader.register(obRequest.OB_REQUEST); 16 | loader.register(request.Policy); 17 | loader.register(request.PolicyCap); 18 | loader.register(request.RequestBody); 19 | loader.register(request.RuleStateDfKey); 20 | loader.register(request.WithNft); 21 | loader.register(withdrawRequest.Witness); 22 | loader.register(withdrawRequest.WITHDRAW_REQ); 23 | loader.register(withdrawRequest.WithdrawRequest); 24 | loader.register(borrowRequest.Witness); 25 | loader.register(borrowRequest.BORROW_REQ); 26 | loader.register(borrowRequest.BorrowRequest); 27 | loader.register(borrowRequest.ReturnPromise); 28 | loader.register(frozenPub.FROZEN_PUB); 29 | } 30 | -------------------------------------------------------------------------------- /client/request/ob-request/functions.ts: -------------------------------------------------------------------------------- 1 | import {PUBLISHED_AT} from ".."; 2 | import {ObjectArg, obj} from "../../_framework/util"; 3 | import {TransactionBlock} from "@mysten/sui.js/transactions"; 4 | 5 | export function init( 6 | txb: TransactionBlock, 7 | otw: ObjectArg 8 | ) { 9 | return txb.moveCall({ 10 | target: `${PUBLISHED_AT}::ob_request::init`, 11 | arguments: [ 12 | obj(txb, otw) 13 | ], 14 | }) 15 | } 16 | -------------------------------------------------------------------------------- /client/request/withdraw-request/functions.ts: -------------------------------------------------------------------------------- 1 | import {PUBLISHED_AT} from ".."; 2 | import {GenericArg, ObjectArg, generic, obj, pure} from "../../_framework/util"; 3 | import {TransactionArgument, TransactionBlock} from "@mysten/sui.js/transactions"; 4 | 5 | export function new_( 6 | txb: TransactionBlock, 7 | typeArg: string, 8 | sender: string | TransactionArgument 9 | ) { 10 | return txb.moveCall({ 11 | target: `${PUBLISHED_AT}::withdraw_request::new`, 12 | typeArguments: [typeArg], 13 | arguments: [ 14 | pure(txb, sender, `address`) 15 | ], 16 | }) 17 | } 18 | 19 | export interface AddReceiptArgs { 20 | self: ObjectArg; rule: GenericArg 21 | } 22 | 23 | export function addReceipt( 24 | txb: TransactionBlock, 25 | typeArgs: [string, string], 26 | args: AddReceiptArgs 27 | ) { 28 | return txb.moveCall({ 29 | target: `${PUBLISHED_AT}::withdraw_request::add_receipt`, 30 | typeArguments: typeArgs, 31 | arguments: [ 32 | obj(txb, args.self), generic(txb, `${typeArgs[1]}`, args.rule) 33 | ], 34 | }) 35 | } 36 | 37 | export interface ConfirmArgs { 38 | self: ObjectArg; policy: ObjectArg 39 | } 40 | 41 | export function confirm( 42 | txb: TransactionBlock, 43 | typeArg: string, 44 | args: ConfirmArgs 45 | ) { 46 | return txb.moveCall({ 47 | target: `${PUBLISHED_AT}::withdraw_request::confirm`, 48 | typeArguments: [typeArg], 49 | arguments: [ 50 | obj(txb, args.self), obj(txb, args.policy) 51 | ], 52 | }) 53 | } 54 | 55 | export function initPolicy( 56 | txb: TransactionBlock, 57 | typeArg: string, 58 | publisher: ObjectArg 59 | ) { 60 | return txb.moveCall({ 61 | target: `${PUBLISHED_AT}::withdraw_request::init_policy`, 62 | typeArguments: [typeArg], 63 | arguments: [ 64 | obj(txb, publisher) 65 | ], 66 | }) 67 | } 68 | 69 | export function innerMut( 70 | txb: TransactionBlock, 71 | typeArg: string, 72 | self: ObjectArg 73 | ) { 74 | return txb.moveCall({ 75 | target: `${PUBLISHED_AT}::withdraw_request::inner_mut`, 76 | typeArguments: [typeArg], 77 | arguments: [ 78 | obj(txb, self) 79 | ], 80 | }) 81 | } 82 | 83 | export function txSender( 84 | txb: TransactionBlock, 85 | typeArg: string, 86 | self: ObjectArg 87 | ) { 88 | return txb.moveCall({ 89 | target: `${PUBLISHED_AT}::withdraw_request::tx_sender`, 90 | typeArguments: [typeArg], 91 | arguments: [ 92 | obj(txb, self) 93 | ], 94 | }) 95 | } 96 | -------------------------------------------------------------------------------- /client/utils/display/functions.ts: -------------------------------------------------------------------------------- 1 | import {PUBLISHED_AT} from ".."; 2 | import {ObjectArg, obj, pure} from "../../_framework/util"; 3 | import {TransactionArgument, TransactionBlock} from "@mysten/sui.js/transactions"; 4 | 5 | export function addressToString( 6 | txb: TransactionBlock, 7 | address: string | TransactionArgument 8 | ) { 9 | return txb.moveCall({ 10 | target: `${PUBLISHED_AT}::display::address_to_string`, 11 | arguments: [ 12 | pure(txb, address, `address`) 13 | ], 14 | }) 15 | } 16 | 17 | export function bytesToString( 18 | txb: TransactionBlock, 19 | bytes: Array | TransactionArgument 20 | ) { 21 | return txb.moveCall({ 22 | target: `${PUBLISHED_AT}::display::bytes_to_string`, 23 | arguments: [ 24 | pure(txb, bytes, `vector`) 25 | ], 26 | }) 27 | } 28 | 29 | export function fromVec( 30 | txb: TransactionBlock, 31 | vec: Array | TransactionArgument 32 | ) { 33 | return txb.moveCall({ 34 | target: `${PUBLISHED_AT}::display::from_vec`, 35 | arguments: [ 36 | pure(txb, vec, `vector<0x1::string::String>`) 37 | ], 38 | }) 39 | } 40 | 41 | export function fromVecMap( 42 | txb: TransactionBlock, 43 | vec: ObjectArg 44 | ) { 45 | return txb.moveCall({ 46 | target: `${PUBLISHED_AT}::display::from_vec_map`, 47 | arguments: [ 48 | obj(txb, vec) 49 | ], 50 | }) 51 | } 52 | 53 | export interface FromVecMapRefArgs { 54 | vec: ObjectArg; isString: boolean | TransactionArgument 55 | } 56 | 57 | export function fromVecMapRef( 58 | txb: TransactionBlock, 59 | args: FromVecMapRefArgs 60 | ) { 61 | return txb.moveCall({ 62 | target: `${PUBLISHED_AT}::display::from_vec_map_ref`, 63 | arguments: [ 64 | obj(txb, args.vec), pure(txb, args.isString, `bool`) 65 | ], 66 | }) 67 | } 68 | 69 | export function fromVecUtf8( 70 | txb: TransactionBlock, 71 | vec: Array | TransactionArgument> | TransactionArgument 72 | ) { 73 | return txb.moveCall({ 74 | target: `${PUBLISHED_AT}::display::from_vec_utf8`, 75 | arguments: [ 76 | pure(txb, vec, `vector>`) 77 | ], 78 | }) 79 | } 80 | 81 | export function idToString( 82 | txb: TransactionBlock, 83 | id: string | TransactionArgument 84 | ) { 85 | return txb.moveCall({ 86 | target: `${PUBLISHED_AT}::display::id_to_string`, 87 | arguments: [ 88 | pure(txb, id, `0x2::object::ID`) 89 | ], 90 | }) 91 | } 92 | -------------------------------------------------------------------------------- /client/utils/index.ts: -------------------------------------------------------------------------------- 1 | export const PACKAGE_ID = "0x859eb18bd5b5e8cc32deb6dfb1c39941008ab3c6e27f0b8ce2364be7102bb7cb"; 2 | export const PUBLISHED_AT = "0x7651f2bd7d83223936c0e25992171c725cd39582e900b16de2466b0b4ff368e2"; 3 | -------------------------------------------------------------------------------- /client/utils/init.ts: -------------------------------------------------------------------------------- 1 | import * as critBit from "./crit-bit/structs"; 2 | import * as dynamicVector from "./dynamic-vector/structs"; 3 | import * as sizedVec from "./sized-vec/structs"; 4 | import * as utilsSupply from "./utils-supply/structs"; 5 | import * as utils from "./utils/structs"; 6 | import {StructClassLoader} from "../_framework/loader"; 7 | 8 | export function registerClasses(loader: StructClassLoader) { 9 | loader.register(utils.IsShared); 10 | loader.register(utils.Marker); 11 | loader.register(critBit.CritbitTree); 12 | loader.register(critBit.InternalNode); 13 | loader.register(critBit.Leaf); 14 | loader.register(dynamicVector.DynVec); 15 | loader.register(sizedVec.SizedVec); 16 | loader.register(utilsSupply.Supply); 17 | } 18 | -------------------------------------------------------------------------------- /client/utils/math/functions.ts: -------------------------------------------------------------------------------- 1 | import {PUBLISHED_AT} from ".."; 2 | import {pure} from "../../_framework/util"; 3 | import {TransactionArgument, TransactionBlock} from "@mysten/sui.js/transactions"; 4 | 5 | export interface MulArgs { 6 | x: bigint | TransactionArgument; y: bigint | TransactionArgument 7 | } 8 | 9 | export function mul( 10 | txb: TransactionBlock, 11 | args: MulArgs 12 | ) { 13 | return txb.moveCall({ 14 | target: `${PUBLISHED_AT}::math::mul`, 15 | arguments: [ 16 | pure(txb, args.x, `u64`), pure(txb, args.y, `u64`) 17 | ], 18 | }) 19 | } 20 | 21 | export interface DivRoundArgs { 22 | x: bigint | TransactionArgument; y: bigint | TransactionArgument 23 | } 24 | 25 | export function divRound( 26 | txb: TransactionBlock, 27 | args: DivRoundArgs 28 | ) { 29 | return txb.moveCall({ 30 | target: `${PUBLISHED_AT}::math::div_round`, 31 | arguments: [ 32 | pure(txb, args.x, `u64`), pure(txb, args.y, `u64`) 33 | ], 34 | }) 35 | } 36 | 37 | export interface MulRoundArgs { 38 | x: bigint | TransactionArgument; y: bigint | TransactionArgument 39 | } 40 | 41 | export function mulRound( 42 | txb: TransactionBlock, 43 | args: MulRoundArgs 44 | ) { 45 | return txb.moveCall({ 46 | target: `${PUBLISHED_AT}::math::mul_round`, 47 | arguments: [ 48 | pure(txb, args.x, `u64`), pure(txb, args.y, `u64`) 49 | ], 50 | }) 51 | } 52 | -------------------------------------------------------------------------------- /contracts/allowlist/Move.lock: -------------------------------------------------------------------------------- 1 | # @generated by Move, please check-in and do not edit manually. 2 | 3 | [move] 4 | version = 0 5 | manifest_digest = "65975D105656503327732F2DD86C85DA921C5C6B8EC2E549D2DF925E0A5B1C03" 6 | deps_digest = "3C4103934B1E040BB6B23F1D610B4EF9F2F1166A50A104EADCF77467C004C600" 7 | 8 | dependencies = [ 9 | { name = "Permissions" }, 10 | { name = "Sui" }, 11 | ] 12 | 13 | [[move.package]] 14 | name = "MoveStdlib" 15 | source = { git = "https://github.com/MystenLabs/sui.git", rev = "mainnet-v1.19.1", subdir = "crates/sui-framework/packages/move-stdlib" } 16 | 17 | [[move.package]] 18 | name = "Permissions" 19 | source = { local = "../permissions" } 20 | 21 | dependencies = [ 22 | { name = "Sui" }, 23 | { name = "Utils" }, 24 | ] 25 | 26 | [[move.package]] 27 | name = "Pseudorandom" 28 | source = { local = "../pseudorandom" } 29 | 30 | dependencies = [ 31 | { name = "Sui" }, 32 | ] 33 | 34 | [[move.package]] 35 | name = "Sui" 36 | source = { git = "https://github.com/MystenLabs/sui.git", rev = "mainnet-v1.19.1", subdir = "crates/sui-framework/packages/sui-framework" } 37 | 38 | dependencies = [ 39 | { name = "MoveStdlib" }, 40 | ] 41 | 42 | [[move.package]] 43 | name = "Utils" 44 | source = { local = "../utils" } 45 | 46 | dependencies = [ 47 | { name = "Pseudorandom" }, 48 | { name = "Sui" }, 49 | ] 50 | -------------------------------------------------------------------------------- /contracts/allowlist/Move.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "Allowlist" 3 | version = "1.7.0" 4 | published-at = "0x165462c17573288e823bbaabc782723f673c528a0dead0f320fe9d99e3ac66aa" 5 | 6 | [dependencies] 7 | Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "mainnet-v1.19.1" } 8 | Permissions = { local = "./../permissions" } 9 | 10 | [addresses] 11 | ob_allowlist = "0x70e34fcd390b767edbddaf7573450528698188c84c5395af8c4b12e3e37622fa" 12 | -------------------------------------------------------------------------------- /contracts/allowlist/sources/init.move: -------------------------------------------------------------------------------- 1 | module ob_allowlist::ob_allowlist { 2 | use sui::package; 3 | use sui::transfer; 4 | use sui::tx_context::{Self, TxContext}; 5 | 6 | struct OB_ALLOWLIST has drop {} 7 | 8 | #[allow(unused_function)] 9 | fun init(otw: OB_ALLOWLIST, ctx: &mut TxContext) { 10 | let pub = package::claim(otw, ctx); 11 | transfer::public_transfer(pub, tx_context::sender(ctx)); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /contracts/allowlist/sources/pub.move: -------------------------------------------------------------------------------- 1 | module ob_allowlist::frozen_pub { 2 | use sui::tx_context::TxContext; 3 | 4 | use ob_permissions::frozen_publisher; 5 | 6 | struct FROZEN_PUB has drop {} 7 | 8 | #[allow(unused_function)] 9 | fun init(otw: FROZEN_PUB, ctx: &mut TxContext) { 10 | frozen_publisher::freeze_from_otw(otw, ctx); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /contracts/authlist/Move.lock: -------------------------------------------------------------------------------- 1 | # @generated by Move, please check-in and do not edit manually. 2 | 3 | [move] 4 | version = 0 5 | manifest_digest = "A00B3FB813F5138704B9021B37825ABBEA1A26C2F97EB40E8D928C5F715AF374" 6 | deps_digest = "3C4103934B1E040BB6B23F1D610B4EF9F2F1166A50A104EADCF77467C004C600" 7 | 8 | dependencies = [ 9 | { name = "Permissions" }, 10 | { name = "Sui" }, 11 | ] 12 | 13 | [[move.package]] 14 | name = "MoveStdlib" 15 | source = { git = "https://github.com/MystenLabs/sui.git", rev = "mainnet-v1.19.1", subdir = "crates/sui-framework/packages/move-stdlib" } 16 | 17 | [[move.package]] 18 | name = "Permissions" 19 | source = { local = "../permissions" } 20 | 21 | dependencies = [ 22 | { name = "Sui" }, 23 | { name = "Utils" }, 24 | ] 25 | 26 | [[move.package]] 27 | name = "Pseudorandom" 28 | source = { local = "../pseudorandom" } 29 | 30 | dependencies = [ 31 | { name = "Sui" }, 32 | ] 33 | 34 | [[move.package]] 35 | name = "Sui" 36 | source = { git = "https://github.com/MystenLabs/sui.git", rev = "mainnet-v1.19.1", subdir = "crates/sui-framework/packages/sui-framework" } 37 | 38 | dependencies = [ 39 | { name = "MoveStdlib" }, 40 | ] 41 | 42 | [[move.package]] 43 | name = "Utils" 44 | source = { local = "../utils" } 45 | 46 | dependencies = [ 47 | { name = "Pseudorandom" }, 48 | { name = "Sui" }, 49 | ] 50 | -------------------------------------------------------------------------------- /contracts/authlist/Move.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "Authlist" 3 | version = "1.7.0" 4 | published-at = "0xfec47309a83e59589f3540c8936b6208d7fa62163b8c3e939937ca0880371c53" 5 | 6 | [dependencies] 7 | Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "mainnet-v1.19.1" } 8 | Permissions = { local = "./../permissions" } 9 | 10 | [addresses] 11 | ob_authlist = "0x228b48911fdc05f8d80ac4334cd734d38dd7db74a0f4e423cb91f736f429ebe4" 12 | -------------------------------------------------------------------------------- /contracts/authlist/sources/init.move: -------------------------------------------------------------------------------- 1 | module ob_authlist::ob_authlist { 2 | use sui::package; 3 | use sui::transfer; 4 | use sui::tx_context::{Self, TxContext}; 5 | 6 | struct OB_AUTHLIST has drop {} 7 | 8 | #[allow(unused_function)] 9 | fun init(otw: OB_AUTHLIST, ctx: &mut TxContext) { 10 | let pub = package::claim(otw, ctx); 11 | transfer::public_transfer(pub, tx_context::sender(ctx)); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /contracts/authlist/sources/pub.move: -------------------------------------------------------------------------------- 1 | module ob_authlist::frozen_pub { 2 | use sui::tx_context::TxContext; 3 | 4 | use ob_permissions::frozen_publisher; 5 | 6 | struct FROZEN_PUB has drop {} 7 | 8 | #[allow(unused_function)] 9 | fun init(otw: FROZEN_PUB, ctx: &mut TxContext) { 10 | frozen_publisher::freeze_from_otw(otw, ctx); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /contracts/critbit/Move.lock: -------------------------------------------------------------------------------- 1 | # @generated by Move, please check-in and do not edit manually. 2 | 3 | [move] 4 | version = 0 5 | manifest_digest = "02BCDE83196E8E24E02B2309FE5A023D390EFDA8B067F3E252BAE7FD0F2559CE" 6 | deps_digest = "F8BBB0CCB2491CA29A3DF03D6F92277A4F3574266507ACD77214D37ECA3F3082" 7 | 8 | dependencies = [ 9 | { name = "Sui" }, 10 | ] 11 | 12 | [[move.package]] 13 | name = "MoveStdlib" 14 | source = { git = "https://github.com/MystenLabs/sui.git", rev = "mainnet-v1.19.1", subdir = "crates/sui-framework/packages/move-stdlib" } 15 | 16 | [[move.package]] 17 | name = "Sui" 18 | source = { git = "https://github.com/MystenLabs/sui.git", rev = "mainnet-v1.19.1", subdir = "crates/sui-framework/packages/sui-framework" } 19 | 20 | dependencies = [ 21 | { name = "MoveStdlib" }, 22 | ] 23 | -------------------------------------------------------------------------------- /contracts/critbit/Move.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "Critbit" 3 | version = "1.7.0" 4 | published-at = "0x1e9ce91148edbd6e474252cdc1c3af2a27fc4c238be617ed56b55275e0e92ef5" 5 | 6 | [dependencies] 7 | Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "mainnet-v1.19.1" } 8 | 9 | [addresses] 10 | critbit = "0x5fb957b59e6b093c17eb3f0ca0a3e8762530244f39f738bd356dbdd43ed9230e" 11 | -------------------------------------------------------------------------------- /contracts/critbit/README.md: -------------------------------------------------------------------------------- 1 | 2 |

OriginByte

3 |
4 | 5 | Origin-Byte is an ecosystem of tools, standards, and smart contracts designed to make life easier for Web3 Game Developers and NFT creators. 6 | From simple artwork to complex gaming assets, we want to help you reach the public, and provide on-chain market infrastructure. 7 | 8 | # Critbit 9 | 10 | A critical bit (critbit) tree is a compact binary prefix tree, 11 | similar to a binary search tree, that stores a prefix-free set of 12 | bitstrings, like n-bit integers or variable-length 0-terminated byte 13 | strings. 14 | 15 | Critbit trees support fast insertion, deletion and iteration operations 16 | as they do not need to be rebalanced. 17 | 18 | ## References 19 | 20 | - [Bernstein 2006](https://cr.yp.to/critbit.html) 21 | - [Langley 2008](https://www.imperialviolet.org/2008/09/29/critbit-trees.html) 22 | - [Langley 2012](https://github.com/agl/critbit) 23 | - [Tcler's Wiki 2021](https://wiki.tcl-lang.org/page/critbit) 24 | 25 | ## Implementation 26 | 27 | This package re-exports 28 | [Deepbook's critbit implementation](https://github.com/MystenLabs/sui/tree/main/crates/sui-framework/packages/deepbook) 29 | which uses a dynamic-field backed structure to allow large tree structures 30 | that don't exceed Sui's object size limit. 31 | -------------------------------------------------------------------------------- /contracts/kiosk/Move.lock: -------------------------------------------------------------------------------- 1 | # @generated by Move, please check-in and do not edit manually. 2 | 3 | [move] 4 | version = 0 5 | manifest_digest = "605CDB10FDD995857D22F2A19C15195A23F9BADCC6F01A74685726CB97BE3CFF" 6 | deps_digest = "060AD7E57DFB13104F21BE5F5C3759D03F0553FC3229247D9A7A6B45F50D03A3" 7 | 8 | dependencies = [ 9 | { name = "Permissions" }, 10 | { name = "Request" }, 11 | { name = "Sui" }, 12 | ] 13 | 14 | [[move.package]] 15 | name = "MoveStdlib" 16 | source = { git = "https://github.com/MystenLabs/sui.git", rev = "mainnet-v1.19.1", subdir = "crates/sui-framework/packages/move-stdlib" } 17 | 18 | [[move.package]] 19 | name = "Permissions" 20 | source = { local = "../permissions" } 21 | 22 | dependencies = [ 23 | { name = "Sui" }, 24 | { name = "Utils" }, 25 | ] 26 | 27 | [[move.package]] 28 | name = "Pseudorandom" 29 | source = { local = "../pseudorandom" } 30 | 31 | dependencies = [ 32 | { name = "Sui" }, 33 | ] 34 | 35 | [[move.package]] 36 | name = "Request" 37 | source = { local = "../request" } 38 | 39 | dependencies = [ 40 | { name = "Permissions" }, 41 | { name = "Sui" }, 42 | ] 43 | 44 | [[move.package]] 45 | name = "Sui" 46 | source = { git = "https://github.com/MystenLabs/sui.git", rev = "mainnet-v1.19.1", subdir = "crates/sui-framework/packages/sui-framework" } 47 | 48 | dependencies = [ 49 | { name = "MoveStdlib" }, 50 | ] 51 | 52 | [[move.package]] 53 | name = "Utils" 54 | source = { local = "../utils" } 55 | 56 | dependencies = [ 57 | { name = "Pseudorandom" }, 58 | { name = "Sui" }, 59 | ] 60 | -------------------------------------------------------------------------------- /contracts/kiosk/Move.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "Kiosk" 3 | version = "1.7.0" 4 | published-at = "0x710fe6944f741058ce916cd16e87953a656b5d339591c1627e73e41f01509d99" 5 | 6 | [dependencies] 7 | Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "mainnet-v1.19.1" } 8 | Permissions = { local = "./../permissions" } 9 | Request = { local = "./../request" } 10 | 11 | [addresses] 12 | ob_kiosk = "0x95a441d389b07437d00dd07e0b6f05f513d7659b13fd7c5d3923c7d9d847199b" 13 | -------------------------------------------------------------------------------- /contracts/kiosk/sources/init.move: -------------------------------------------------------------------------------- 1 | module ob_kiosk::kiosk { 2 | use sui::package; 3 | use sui::transfer; 4 | use sui::tx_context::{Self, TxContext}; 5 | 6 | struct KIOSK has drop {} 7 | 8 | #[allow(unused_function)] 9 | fun init(otw: KIOSK, ctx: &mut TxContext) { 10 | let pub = package::claim(otw, ctx); 11 | transfer::public_transfer(pub, tx_context::sender(ctx)); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /contracts/kiosk/sources/pub.move: -------------------------------------------------------------------------------- 1 | module ob_kiosk::frozen_pub { 2 | use sui::tx_context::TxContext; 3 | 4 | use ob_permissions::frozen_publisher; 5 | 6 | struct FROZEN_PUB has drop {} 7 | 8 | #[allow(unused_function)] 9 | fun init(otw: FROZEN_PUB, ctx: &mut TxContext) { 10 | frozen_publisher::freeze_from_otw(otw, ctx); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /contracts/launchpad/Move.lock: -------------------------------------------------------------------------------- 1 | # @generated by Move, please check-in and do not edit manually. 2 | 3 | [move] 4 | version = 0 5 | manifest_digest = "461044ADFC5BFF564B120D25764387C867ACD614C75866CF29CC57E3E5C0E117" 6 | deps_digest = "397E6A9F7A624706DBDFEE056CE88391A15876868FD18A88504DA74EB458D697" 7 | 8 | dependencies = [ 9 | { name = "Kiosk" }, 10 | { name = "Originmate" }, 11 | { name = "Pseudorandom" }, 12 | { name = "Sui" }, 13 | { name = "Utils" }, 14 | ] 15 | 16 | [[move.package]] 17 | name = "Kiosk" 18 | source = { local = "../kiosk" } 19 | 20 | dependencies = [ 21 | { name = "Permissions" }, 22 | { name = "Request" }, 23 | { name = "Sui" }, 24 | ] 25 | 26 | [[move.package]] 27 | name = "MoveStdlib" 28 | source = { git = "https://github.com/MystenLabs/sui.git", rev = "mainnet-v1.19.1", subdir = "crates/sui-framework/packages/move-stdlib" } 29 | 30 | [[move.package]] 31 | name = "Originmate" 32 | source = { local = "../originmate" } 33 | 34 | dependencies = [ 35 | { name = "Sui" }, 36 | ] 37 | 38 | [[move.package]] 39 | name = "Permissions" 40 | source = { local = "../permissions" } 41 | 42 | dependencies = [ 43 | { name = "Sui" }, 44 | { name = "Utils" }, 45 | ] 46 | 47 | [[move.package]] 48 | name = "Pseudorandom" 49 | source = { local = "../pseudorandom" } 50 | 51 | dependencies = [ 52 | { name = "Sui" }, 53 | ] 54 | 55 | [[move.package]] 56 | name = "Request" 57 | source = { local = "../request" } 58 | 59 | dependencies = [ 60 | { name = "Permissions" }, 61 | { name = "Sui" }, 62 | ] 63 | 64 | [[move.package]] 65 | name = "Sui" 66 | source = { git = "https://github.com/MystenLabs/sui.git", rev = "mainnet-v1.19.1", subdir = "crates/sui-framework/packages/sui-framework" } 67 | 68 | dependencies = [ 69 | { name = "MoveStdlib" }, 70 | ] 71 | 72 | [[move.package]] 73 | name = "Utils" 74 | source = { local = "../utils" } 75 | 76 | dependencies = [ 77 | { name = "Pseudorandom" }, 78 | { name = "Sui" }, 79 | ] 80 | -------------------------------------------------------------------------------- /contracts/launchpad/Move.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "Launchpad" 3 | version = "1.7.0" 4 | published-at = "0x7b36997c1606ce7421d433eeafd52ace7921dad632ee6a2ef944e5b3f5479b3c" 5 | 6 | [dependencies] 7 | Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "mainnet-v1.19.1" } 8 | Originmate = { local = "./../originmate" } 9 | Kiosk = { local = "./../kiosk" } 10 | Pseudorandom = { local = "./../pseudorandom" } 11 | Utils = { local = "./../utils" } 12 | 13 | [addresses] 14 | ob_launchpad = "0xc74531639fadfb02d30f05f37de4cf1e1149ed8d23658edd089004830068180b" 15 | -------------------------------------------------------------------------------- /contracts/launchpad/sources/init.move: -------------------------------------------------------------------------------- 1 | module ob_launchpad::launchpad { 2 | use sui::package; 3 | use sui::transfer; 4 | use sui::tx_context::{Self, TxContext}; 5 | 6 | struct LAUNCHPAD has drop {} 7 | 8 | #[allow(unused_function)] 9 | fun init(otw: LAUNCHPAD, ctx: &mut TxContext) { 10 | let pub = package::claim(otw, ctx); 11 | transfer::public_transfer(pub, tx_context::sender(ctx)); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /contracts/launchpad/sources/pub.move: -------------------------------------------------------------------------------- 1 | module ob_launchpad::frozen_pub { 2 | use sui::tx_context::TxContext; 3 | 4 | use ob_permissions::frozen_publisher; 5 | 6 | struct FROZEN_PUB has drop {} 7 | 8 | #[allow(unused_function)] 9 | fun init(otw: FROZEN_PUB, ctx: &mut TxContext) { 10 | frozen_publisher::freeze_from_otw(otw, ctx); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /contracts/launchpad/tests/whitelist_with_cert.move: -------------------------------------------------------------------------------- 1 | #[test_only] 2 | #[lint_allow(share_owned)] 3 | module ob_launchpad::test_whitelist_with_cert { 4 | use sui::test_scenario::{Self, ctx}; 5 | 6 | use sui::object::UID; 7 | use sui::transfer; 8 | 9 | use ob_launchpad::listing; 10 | use ob_launchpad::market_whitelist; 11 | use ob_launchpad::fixed_price; 12 | use ob_launchpad::test_listing; 13 | 14 | use sui::sui::SUI; 15 | 16 | struct Foo has key, store { 17 | id: UID, 18 | } 19 | struct Witness has drop {} 20 | 21 | const OWNER: address = @0xA1C05; 22 | const CREATOR: address = @0xA1C05; 23 | 24 | #[test] 25 | public fun create_whitelist() { 26 | let scenario = test_scenario::begin(CREATOR); 27 | 28 | let listing = test_listing::init_listing(CREATOR, &mut scenario); 29 | 30 | // 2. Create `Warehouse` 31 | let inventory_id = listing::create_warehouse( 32 | &mut listing, 33 | ctx(&mut scenario), 34 | ); 35 | 36 | let venue_id = fixed_price::create_venue( 37 | &mut listing, inventory_id, true, 100, ctx(&mut scenario) 38 | ); 39 | 40 | let cert = market_whitelist::new(&listing, venue_id, ctx(&mut scenario)); 41 | 42 | transfer::public_transfer(cert, OWNER); 43 | transfer::public_share_object(listing); 44 | test_scenario::end(scenario); 45 | } 46 | 47 | #[test] 48 | #[expected_failure(abort_code = ob_launchpad::listing::EUndefinedVenue)] 49 | public fun fail_spoof_whitelist() { 50 | let scenario = test_scenario::begin(CREATOR); 51 | 52 | let listing = test_listing::init_listing(CREATOR, &mut scenario); 53 | 54 | // 2. Create `Warehouse` 55 | let inventory_id = listing::create_warehouse( 56 | &mut listing, 57 | ctx(&mut scenario), 58 | ); 59 | 60 | let venue_id = fixed_price::create_venue( 61 | &mut listing, inventory_id, true, 100, ctx(&mut scenario) 62 | ); 63 | 64 | transfer::public_share_object(listing); 65 | 66 | test_scenario::next_tx(&mut scenario, OWNER); 67 | let fake_listing = test_listing::init_listing(OWNER, &mut scenario); 68 | 69 | let cert = market_whitelist::new(&fake_listing, venue_id, ctx(&mut scenario)); 70 | 71 | transfer::public_transfer(cert, OWNER); 72 | 73 | transfer::public_share_object(fake_listing); 74 | test_scenario::end(scenario); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /contracts/liquidity_layer_v1/Move.lock: -------------------------------------------------------------------------------- 1 | # @generated by Move, please check-in and do not edit manually. 2 | 3 | [move] 4 | version = 0 5 | manifest_digest = "DDEC5BF392E7A52F55EB3C4DECF0547C4E2F706A7737BD00EEF97EB534D01CF2" 6 | deps_digest = "52B406A7A21811BEF51751CF88DA0E76DAEFFEAC888D4F4060B1A72BBE7D8D35" 7 | 8 | dependencies = [ 9 | { name = "Kiosk" }, 10 | { name = "Originmate" }, 11 | { name = "Permissions" }, 12 | { name = "Request" }, 13 | { name = "Sui" }, 14 | { name = "Utils" }, 15 | ] 16 | 17 | [[move.package]] 18 | name = "Kiosk" 19 | source = { local = "../kiosk" } 20 | 21 | dependencies = [ 22 | { name = "Permissions" }, 23 | { name = "Request" }, 24 | { name = "Sui" }, 25 | ] 26 | 27 | [[move.package]] 28 | name = "MoveStdlib" 29 | source = { git = "https://github.com/MystenLabs/sui.git", rev = "mainnet-v1.19.1", subdir = "crates/sui-framework/packages/move-stdlib" } 30 | 31 | [[move.package]] 32 | name = "Originmate" 33 | source = { local = "../originmate" } 34 | 35 | dependencies = [ 36 | { name = "Sui" }, 37 | ] 38 | 39 | [[move.package]] 40 | name = "Permissions" 41 | source = { local = "../permissions" } 42 | 43 | dependencies = [ 44 | { name = "Sui" }, 45 | { name = "Utils" }, 46 | ] 47 | 48 | [[move.package]] 49 | name = "Pseudorandom" 50 | source = { local = "../pseudorandom" } 51 | 52 | dependencies = [ 53 | { name = "Sui" }, 54 | ] 55 | 56 | [[move.package]] 57 | name = "Request" 58 | source = { local = "../request" } 59 | 60 | dependencies = [ 61 | { name = "Permissions" }, 62 | { name = "Sui" }, 63 | ] 64 | 65 | [[move.package]] 66 | name = "Sui" 67 | source = { git = "https://github.com/MystenLabs/sui.git", rev = "mainnet-v1.19.1", subdir = "crates/sui-framework/packages/sui-framework" } 68 | 69 | dependencies = [ 70 | { name = "MoveStdlib" }, 71 | ] 72 | 73 | [[move.package]] 74 | name = "Utils" 75 | source = { local = "../utils" } 76 | 77 | dependencies = [ 78 | { name = "Pseudorandom" }, 79 | { name = "Sui" }, 80 | ] 81 | -------------------------------------------------------------------------------- /contracts/liquidity_layer_v1/Move.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "LiquidityLayerV1" 3 | version = "1.7.0" 4 | published-at = "0x509f287d326291d1066e20e2eb8adbbe1c8283e895d58c23afe7c9228645def2" 5 | 6 | [dependencies] 7 | Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "mainnet-v1.19.1" } 8 | Originmate = { local = "./../originmate" } 9 | Permissions = { local = "./../permissions" } 10 | Request = { local = "./../request" } 11 | Kiosk = { local = "./../kiosk" } 12 | Utils = { local = "./../utils" } 13 | 14 | [addresses] 15 | liquidity_layer_v1 = "0x4e0629fa51a62b0c1d7c7b9fc89237ec5b6f630d7798ad3f06d820afb93a995a" 16 | -------------------------------------------------------------------------------- /contracts/liquidity_layer_v1/sources/init.move: -------------------------------------------------------------------------------- 1 | module liquidity_layer_v1::liquidity_layer { 2 | use sui::package; 3 | use sui::transfer; 4 | use sui::tx_context::{Self, TxContext}; 5 | 6 | struct LIQUIDITY_LAYER has drop {} 7 | 8 | #[allow(unused_function)] 9 | fun init(otw: LIQUIDITY_LAYER, ctx: &mut TxContext) { 10 | let pub = package::claim(otw, ctx); 11 | transfer::public_transfer(pub, tx_context::sender(ctx)); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /contracts/liquidity_layer_v1/sources/pub.move: -------------------------------------------------------------------------------- 1 | module liquidity_layer_v1::frozen_pub { 2 | use sui::tx_context::TxContext; 3 | 4 | use ob_permissions::frozen_publisher; 5 | 6 | struct FROZEN_PUB has drop {} 7 | 8 | #[allow(unused_function)] 9 | fun init(otw: FROZEN_PUB, ctx: &mut TxContext) { 10 | frozen_publisher::freeze_from_otw(otw, ctx); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /contracts/nft_protocol/Move.lock: -------------------------------------------------------------------------------- 1 | # @generated by Move, please check-in and do not edit manually. 2 | 3 | [move] 4 | version = 0 5 | manifest_digest = "98E4F5F7A18F104C1C4FD289A4E68987F841588A02E50EA865E921CBEB18F325" 6 | deps_digest = "8227D341C0550A37580C10FA45FE148A465225149C69D179737E0FE454AD6AEC" 7 | 8 | dependencies = [ 9 | { name = "Allowlist" }, 10 | { name = "Authlist" }, 11 | { name = "Kiosk" }, 12 | { name = "Originmate" }, 13 | { name = "Permissions" }, 14 | { name = "Pseudorandom" }, 15 | { name = "Request" }, 16 | { name = "Sui" }, 17 | { name = "Utils" }, 18 | ] 19 | 20 | [[move.package]] 21 | name = "Allowlist" 22 | source = { local = "../allowlist" } 23 | 24 | dependencies = [ 25 | { name = "Permissions" }, 26 | { name = "Sui" }, 27 | ] 28 | 29 | [[move.package]] 30 | name = "Authlist" 31 | source = { local = "../authlist" } 32 | 33 | dependencies = [ 34 | { name = "Permissions" }, 35 | { name = "Sui" }, 36 | ] 37 | 38 | [[move.package]] 39 | name = "Kiosk" 40 | source = { local = "../kiosk" } 41 | 42 | dependencies = [ 43 | { name = "Permissions" }, 44 | { name = "Request" }, 45 | { name = "Sui" }, 46 | ] 47 | 48 | [[move.package]] 49 | name = "MoveStdlib" 50 | source = { git = "https://github.com/MystenLabs/sui.git", rev = "mainnet-v1.19.1", subdir = "crates/sui-framework/packages/move-stdlib" } 51 | 52 | [[move.package]] 53 | name = "Originmate" 54 | source = { local = "../originmate" } 55 | 56 | dependencies = [ 57 | { name = "Sui" }, 58 | ] 59 | 60 | [[move.package]] 61 | name = "Permissions" 62 | source = { local = "../permissions" } 63 | 64 | dependencies = [ 65 | { name = "Sui" }, 66 | { name = "Utils" }, 67 | ] 68 | 69 | [[move.package]] 70 | name = "Pseudorandom" 71 | source = { local = "../pseudorandom" } 72 | 73 | dependencies = [ 74 | { name = "Sui" }, 75 | ] 76 | 77 | [[move.package]] 78 | name = "Request" 79 | source = { local = "../request" } 80 | 81 | dependencies = [ 82 | { name = "Permissions" }, 83 | { name = "Sui" }, 84 | ] 85 | 86 | [[move.package]] 87 | name = "Sui" 88 | source = { git = "https://github.com/MystenLabs/sui.git", rev = "mainnet-v1.19.1", subdir = "crates/sui-framework/packages/sui-framework" } 89 | 90 | dependencies = [ 91 | { name = "MoveStdlib" }, 92 | ] 93 | 94 | [[move.package]] 95 | name = "Utils" 96 | source = { local = "../utils" } 97 | 98 | dependencies = [ 99 | { name = "Pseudorandom" }, 100 | { name = "Sui" }, 101 | ] 102 | -------------------------------------------------------------------------------- /contracts/nft_protocol/Move.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "NftProtocol" 3 | version = "1.7.0" 4 | published-at = "0xbdd1811dd6e8feb2c7311d193bbf92cb45d3d6a8fb2b6ec60dc19adf20c18796" 5 | 6 | [dependencies] 7 | Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "mainnet-v1.19.1" } 8 | Originmate = { local = "./../originmate" } 9 | Permissions = { local = "./../permissions" } 10 | Authlist = { local = "./../authlist" } 11 | Allowlist = { local = "./../allowlist" } 12 | Request = { local = "./../request" } 13 | Kiosk = { local = "./../kiosk" } 14 | Pseudorandom = { local = "./../pseudorandom" } 15 | Utils = { local = "./../utils" } 16 | 17 | [addresses] 18 | nft_protocol = "0xbc3df36be17f27ac98e3c839b2589db8475fa07b20657b08e8891e3aaf5ee5f9" 19 | -------------------------------------------------------------------------------- /contracts/nft_protocol/sources/init.move: -------------------------------------------------------------------------------- 1 | module nft_protocol::nft_protocol { 2 | use sui::package; 3 | use sui::transfer; 4 | use sui::object::{Self, ID}; 5 | use sui::tx_context::{Self, TxContext}; 6 | 7 | use ob_allowlist::allowlist; 8 | 9 | use ob_authlist::authlist; 10 | 11 | struct NFT_PROTOCOL has drop {} 12 | 13 | #[allow(unused_function)] 14 | fun init(otw: NFT_PROTOCOL, ctx: &mut TxContext) { 15 | let pub = package::claim(otw, ctx); 16 | init_allowlist(ctx); 17 | init_authlist(ctx); 18 | 19 | transfer::public_transfer(pub, tx_context::sender(ctx)); 20 | } 21 | 22 | #[lint_allow(share_owned, self_transfer)] 23 | /// Initialize official OriginByte `Allowlist` 24 | public fun init_allowlist(ctx: &mut TxContext): (ID, ID) { 25 | let (allowlist, cap) = allowlist::new(ctx); 26 | 27 | let allowlist_id = object::id(&allowlist); 28 | let cap_id = object::id(&cap); 29 | 30 | transfer::public_transfer(cap, tx_context::sender(ctx)); 31 | transfer::public_share_object(allowlist); 32 | (allowlist_id, cap_id) 33 | } 34 | 35 | const PERMISSIONLESS_PUBLIC_KEY: address = @0x8a1a8348dde5d979c85553c03e204c73efc3b91a2c9ce96b1004c9ec26eaacc8; 36 | const PERMISSIONLESS_PRIVATE_KEY: address = @0xac5dbb29bea100f5f6382ebcb116afc66fc7b05ff64d2d1e3fc60849504a29f0; 37 | 38 | #[lint_allow(share_owned, self_transfer)] 39 | /// Initialize official OriginByte `Authlist` 40 | /// 41 | /// This initially contains a public keypair such that users can sign P2P 42 | /// transactions client-side until ecosystem achieves wide adoption. 43 | /// 44 | /// This keypair is expected to be removed in the early stages of mainnet 45 | /// and replaced with genuine authorities. 46 | public fun init_authlist(ctx: &mut TxContext): (ID, ID) { 47 | let (authlist, cap) = authlist::new(ctx); 48 | 49 | authlist::insert_authority( 50 | &cap, &mut authlist, authlist::address_to_bytes(PERMISSIONLESS_PUBLIC_KEY), 51 | ); 52 | 53 | let authlist_id = object::id(&authlist); 54 | let cap_id = object::id(&cap); 55 | 56 | transfer::public_transfer(cap, tx_context::sender(ctx)); 57 | transfer::public_share_object(authlist); 58 | (authlist_id, cap_id) 59 | } 60 | 61 | public fun permissionless_public_key(): address { 62 | PERMISSIONLESS_PUBLIC_KEY 63 | } 64 | 65 | public fun permissionless_private_key(): address { 66 | PERMISSIONLESS_PRIVATE_KEY 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /contracts/nft_protocol/sources/pub.move: -------------------------------------------------------------------------------- 1 | module nft_protocol::frozen_pub { 2 | use sui::tx_context::TxContext; 3 | 4 | use ob_permissions::frozen_publisher; 5 | 6 | struct FROZEN_PUB has drop {} 7 | 8 | #[allow(unused_function)] 9 | fun init(otw: FROZEN_PUB, ctx: &mut TxContext) { 10 | frozen_publisher::freeze_from_otw(otw, ctx); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /contracts/nft_protocol/sources/rules/deprecated/session_tokens.move: -------------------------------------------------------------------------------- 1 | module nft_protocol::session_token { 2 | use std::type_name::TypeName; 3 | use std::option::Option; 4 | 5 | use sui::object::{ID, UID}; 6 | use sui::tx_context::{TxContext}; 7 | use sui::kiosk::Kiosk; 8 | 9 | use ob_request::request::{Policy, PolicyCap, WithNft}; 10 | use ob_request::borrow_request::BorrowRequest; 11 | 12 | use originmate::typed_id::TypedID; 13 | 14 | const EDeprecatedApi: u64 = 998; 15 | 16 | #[allow(unused_field)] 17 | struct SessionToken has key, store { 18 | id: UID, 19 | nft_id: ID, 20 | // We add type reflection here due to it being an option, 21 | // since the borrow can occur globally, in which case the 22 | // Option is None 23 | field: Option, 24 | expiry_ms: u64, 25 | timeout_id: ID, 26 | entity: address, 27 | } 28 | 29 | struct SessionTokenRule has drop {} 30 | #[allow(unused_field)] 31 | struct TimeOutDfKey has store, copy, drop { nft_id: ID } 32 | 33 | #[allow(unused_field)] 34 | struct TimeOut has key, store { 35 | id: UID, 36 | expiry_ms: u64, 37 | access_token: ID, 38 | } 39 | 40 | public fun issue_session_token( 41 | _kiosk: &mut Kiosk, 42 | _nft_id: TypedID, 43 | _receiver: address, 44 | _expiry_ms: u64, 45 | _ctx: &mut TxContext, 46 | ): ID { 47 | abort(EDeprecatedApi) 48 | } 49 | 50 | #[allow(unused_type_parameter)] 51 | public fun issue_session_token_field( 52 | _kiosk: &mut Kiosk, 53 | _nft_id: TypedID, 54 | _receiver: address, 55 | _expiry_ms: u64, 56 | _ctx: &mut TxContext, 57 | ) { 58 | abort(EDeprecatedApi) 59 | } 60 | 61 | /// Registers a type to use `AccessPolicy` during the borrowing. 62 | public entry fun enforce( 63 | _policy: &mut Policy>, _cap: &PolicyCap, 64 | ) { 65 | abort(EDeprecatedApi) 66 | } 67 | 68 | public fun drop(_policy: &mut Policy>, _cap: &PolicyCap) { 69 | abort(EDeprecatedApi) 70 | } 71 | 72 | public fun confirm( 73 | _self: &SessionToken, _req: &mut BorrowRequest, 74 | ) { 75 | abort(EDeprecatedApi) 76 | } 77 | 78 | public fun assert_field_auth( 79 | _self: &SessionToken, 80 | _req: &BorrowRequest 81 | ) { 82 | abort(EDeprecatedApi) 83 | } 84 | 85 | public fun assert_parent_auth( 86 | _self: &SessionToken, 87 | _req: &BorrowRequest 88 | ) { 89 | abort(EDeprecatedApi) 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /contracts/nft_protocol/sources/rules/transfer_token.move: -------------------------------------------------------------------------------- 1 | module nft_protocol::transfer_token { 2 | use sui::object::{Self, UID, ID}; 3 | use sui::transfer; 4 | use sui::tx_context::TxContext; 5 | 6 | use ob_request::request::{Self, RequestBody, Policy, PolicyCap, WithNft}; 7 | use ob_permissions::witness::Witness as DelegatedWitness; 8 | 9 | // === Structs === 10 | 11 | struct TransferToken has key { 12 | id: UID, 13 | receiver: address, 14 | } 15 | 16 | struct TransferTokenRule has drop {} 17 | 18 | // === Management === 19 | 20 | /// Creates a new `TransferToken` list 21 | public fun new( 22 | _witness: DelegatedWitness, 23 | future_recipient: address, 24 | ctx: &mut TxContext, 25 | ): TransferToken { 26 | TransferToken { 27 | id: object::new(ctx), 28 | receiver: future_recipient, 29 | } 30 | } 31 | 32 | /// Creates a new `TransferToken` list 33 | public fun create_and_transfer( 34 | witness: DelegatedWitness, 35 | receiver: address, 36 | current_owner: address, 37 | ctx: &mut TxContext, 38 | ): ID { 39 | let token = new(witness, receiver, ctx); 40 | let token_id = object::id(&token); 41 | 42 | transfer::transfer(token, current_owner); 43 | token_id 44 | } 45 | 46 | // === Actions === 47 | 48 | /// Registers collection to use `Allowlist` during the transfer. 49 | public entry fun enforce( 50 | policy: &mut Policy>, cap: &PolicyCap, 51 | ) { 52 | request::enforce_rule_no_state, TransferTokenRule>(policy, cap); 53 | } 54 | 55 | public fun drop(policy: &mut Policy>, cap: &PolicyCap) { 56 | request::drop_rule_no_state, TransferTokenRule>(policy, cap); 57 | } 58 | 59 | /// Confirms that the transfer is allowed by the `Allowlist`. 60 | /// It adds a signature to the request. 61 | /// In the end, if the allowlist rule is included in the transfer policy, 62 | /// the transfer request can only be finished if this rule is present. 63 | public fun confirm( 64 | nft: T, token: TransferToken, req: &mut RequestBody>, 65 | ) { 66 | let TransferToken {id, receiver} = token; 67 | object::delete(id); 68 | 69 | transfer::public_transfer(nft, receiver); 70 | request::add_receipt(req, &TransferTokenRule {}); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /contracts/nft_protocol/sources/standards/tags.move: -------------------------------------------------------------------------------- 1 | /// Module of NFT and Collection Tags. 2 | /// 3 | /// This module functions as a helper module for setting up NFT collection tags. 4 | /// Adding strings manually is prone to fat-finger error, among other manual errors, 5 | /// therefore this module provides a standardized way of injecting Tags to a collection 6 | /// 7 | /// Tags allows wallets to organize the NFT display based on categories, such as 8 | /// Art, Collectibles, Profile Pictures, among others. 9 | /// 10 | /// We cannot enforce a maximum number of categories chosen because the Sui's 11 | /// Display does not allow for such constraint to be added. This constriant should 12 | /// rather be enforced on the client side by clipping the vector field. 13 | module nft_protocol::tags { 14 | use std::string::{Self, String}; 15 | 16 | public fun art(): String { 17 | string::utf8(b"Art") 18 | } 19 | 20 | public fun profile_picture(): String { 21 | string::utf8(b"ProfilePicture") 22 | } 23 | 24 | /// An example of a collectible would be digital Baseball cards 25 | public fun collectible(): String { 26 | string::utf8(b"Collectible") 27 | } 28 | 29 | public fun game_asset(): String { 30 | string::utf8(b"GameAsset") 31 | } 32 | 33 | /// A tokenised asset is a real world asset represented on-chian, 34 | /// i.e. insurance policies, loan contracts, etc. 35 | public fun tokenised_asset(): String { 36 | string::utf8(b"TokenisedAsset") 37 | } 38 | 39 | /// Tickers are what's called the abbreviation used to uniquely identify 40 | /// publicly traded assets, i.e. Tesla trades as $TSLA and Amazon as $AMZN. 41 | /// Crypto asset tickers themselves can be minted and sold as NFTs. 42 | public fun symbol(): String { 43 | string::utf8(b"Ticker") 44 | } 45 | 46 | public fun domain_name(): String { 47 | string::utf8(b"DomainName") 48 | } 49 | 50 | public fun music(): String { 51 | string::utf8(b"Music") 52 | } 53 | 54 | public fun video(): String { 55 | string::utf8(b"Video") 56 | } 57 | 58 | public fun ticket(): String { 59 | string::utf8(b"Ticket") 60 | } 61 | 62 | public fun license(): String { 63 | string::utf8(b"License") 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /contracts/nft_protocol/sources/standards/url.move: -------------------------------------------------------------------------------- 1 | /// Module of the `UrlDomain` 2 | /// 3 | /// Used to associate a URL with `Collection` or `Nft`.add 4 | /// 5 | /// Interoperability functions are delegated to the `display_ext` module. 6 | module nft_protocol::url { 7 | use sui::url::Url; 8 | use sui::object::UID; 9 | use sui::dynamic_field as df; 10 | 11 | use ob_utils::utils::{marker, Marker}; 12 | 13 | /// `UrlDomain` was not defined 14 | /// 15 | /// Call `url::add_domain` to add `UrlDomain`. 16 | const EUndefinedUrl: u64 = 1; 17 | 18 | /// `UrlDomain` already defined 19 | /// 20 | /// Call `url::borrow_domain` to borrow domain. 21 | const EExistingUrl: u64 = 2; 22 | 23 | // === Interoperability === 24 | 25 | /// Returns whether `Url` is registered on `Nft` 26 | public fun has_domain(nft: &UID): bool { 27 | df::exists_with_type, Url>( 28 | nft, marker(), 29 | ) 30 | } 31 | 32 | /// Borrows `Url` from `Nft` 33 | /// 34 | /// #### Panics 35 | /// 36 | /// Panics if `Url` is not registered on the `Nft` 37 | public fun borrow_domain(nft: &UID): &Url { 38 | assert_url(nft); 39 | df::borrow(nft, marker()) 40 | } 41 | 42 | /// Mutably borrows `Url` from `Nft` 43 | /// 44 | /// #### Panics 45 | /// 46 | /// Panics if `Url` is not registered on the `Nft` 47 | public fun borrow_domain_mut(nft: &mut UID): &mut Url { 48 | assert_url(nft); 49 | df::borrow_mut(nft, marker()) 50 | } 51 | 52 | /// Adds `Url` to `Nft` 53 | /// 54 | /// #### Panics 55 | /// 56 | /// Panics if `Url` domain already exists 57 | public fun add_domain( 58 | nft: &mut UID, 59 | domain: Url, 60 | ) { 61 | assert_no_url(nft); 62 | df::add(nft, marker(), domain); 63 | } 64 | 65 | /// Remove `Url` from `Nft` 66 | /// 67 | /// #### Panics 68 | /// 69 | /// Panics if `Url` domain doesnt exist 70 | public fun remove_domain(nft: &mut UID): Url { 71 | assert_url(nft); 72 | df::remove(nft, marker()) 73 | } 74 | 75 | // === Assertions === 76 | 77 | /// Asserts that `Url` is registered on `Nft` 78 | /// 79 | /// #### Panics 80 | /// 81 | /// Panics if `Url` is not registered 82 | public fun assert_url(nft: &UID) { 83 | assert!(has_domain(nft), EUndefinedUrl); 84 | } 85 | 86 | /// Asserts that `Url` is not registered on `Nft` 87 | /// 88 | /// #### Panics 89 | /// 90 | /// Panics if `Url` is registered 91 | public fun assert_no_url(nft: &UID) { 92 | assert!(!has_domain(nft), EExistingUrl); 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /contracts/originmate/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to this project will be documented in this file. 4 | 5 | The format is based on [Keep a 6 | Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to 7 | [Semantic Versioning](https://semver.org/spec/v2.0.0.html). 8 | 9 | ## [3.0.0] - 2023-04-02 10 | 11 | ### Added 12 | 13 | - `balances` 14 | 15 | ### Removed 16 | 17 | - `acl` 18 | - `virtual_block` 19 | - `box::PrivateBox` 20 | - `governance` 21 | 22 | ## [2.6.0] - 2023-02-22 23 | 24 | ### Changed 25 | 26 | - Updated Sui dep to `0.27.0` 27 | - 28 | 29 | ## [2.5.1] - 2023-02-18 30 | 31 | ### Changed 32 | 33 | - Updated Sui dep to `0.26.1` 34 | 35 | ## [2.5.0] - 2023-02-16 36 | 37 | ### Changed 38 | 39 | - Updated Sui dep to `0.26.0` 40 | 41 | ## [2.4.0] - 2023-02-13 42 | 43 | ### Changed 44 | 45 | - Updated Sui dep to `0.25.0` 46 | 47 | ## [2.3.0] - 2023-01-26 48 | 49 | ### Changed 50 | 51 | - Updated Sui dep to `0.24.0` 52 | 53 | ## [2.2.0] - 2023-01-26 54 | 55 | ### Changed 56 | 57 | - Updated Sui dep to `0.23.0` 58 | 59 | ## [2.1.0] - 2023-01-23 60 | 61 | ### Changed 62 | 63 | - Updated Sui dep to `0.22.0` 64 | 65 | ## [2.0.0] - 2023-01-13 66 | 67 | ### Changed 68 | 69 | - Updated Sui dep to `0.21.0` 70 | 71 | ## [1.9.0] - 2023-01-13 72 | 73 | ### Changed 74 | 75 | - Updated Sui dep to `0.20.0` 76 | 77 | ### Added 78 | 79 | - Module `object_vec` 80 | - Module `object_box` 81 | - Util function `vectors::from_vec_to_map` 82 | -------------------------------------------------------------------------------- /contracts/originmate/Move.lock: -------------------------------------------------------------------------------- 1 | # @generated by Move, please check-in and do not edit manually. 2 | 3 | [move] 4 | version = 0 5 | manifest_digest = "A032A885DBA756F92EA7BE1BD1126B5BBC682DF3983A0537DC9DB51ED574C773" 6 | deps_digest = "F8BBB0CCB2491CA29A3DF03D6F92277A4F3574266507ACD77214D37ECA3F3082" 7 | 8 | dependencies = [ 9 | { name = "Sui" }, 10 | ] 11 | 12 | [[move.package]] 13 | name = "MoveStdlib" 14 | source = { git = "https://github.com/MystenLabs/sui.git", rev = "mainnet-v1.19.1", subdir = "crates/sui-framework/packages/move-stdlib" } 15 | 16 | [[move.package]] 17 | name = "Sui" 18 | source = { git = "https://github.com/MystenLabs/sui.git", rev = "mainnet-v1.19.1", subdir = "crates/sui-framework/packages/sui-framework" } 19 | 20 | dependencies = [ 21 | { name = "MoveStdlib" }, 22 | ] 23 | -------------------------------------------------------------------------------- /contracts/originmate/Move.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "Originmate" 3 | version = "3.6.0" 4 | authors = [ 5 | "David Lucid ", 6 | "Jakub Labor ", 7 | "Michael Bausano ", 8 | "Nuno Boavida ", 9 | ] 10 | published-at = "0x40fccbe644cb7e496309af17fc76574e5ac436ae8533a6f830d596264fbc5bb2" 11 | 12 | [dependencies] 13 | Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "mainnet-v1.19.1" } 14 | 15 | [addresses] 16 | originmate = "0xed6c6fe0732be937f4379bc0b471f0f6bfbe0e8741968009e0f01e6de3d59f32" 17 | -------------------------------------------------------------------------------- /contracts/originmate/README.md: -------------------------------------------------------------------------------- 1 | # Originmate 2 | 3 | A library of module building blocks for Move on Sui. 4 | 5 | Movemate provides an advanced standard library of common modules in the Move ecosystem (working in tandem with the native frameworks), focusing on security, efficiency, composability, and ease of implementation. 6 | 7 | Forked from: [pentagonxyz/movemate](https://github.com/pentagonxyz/movemate) 8 | 9 | ## Modules 10 | 11 | - `bcd`: Binary canonical Deserialization. Convert `vector` to `u64` and `u128`. 12 | - `bloom_filter`: Space-efficient probabilistic data structure for checking if an element is part of a set. 13 | - `box`: Transfer objects with the `store` ability but not the `key` ability. 14 | - `crit_bit`: [Crit-bit trees](https://cr.yp.to/critbit.html) data structure. (Thanks to Econia.) 15 | - `crit_bit_u64`: [Crit-bit trees](https://cr.yp.to/critbit.html) data structure. (Thanks to Econia.) Uses `u64` keys. 16 | - `date`: Date conversion library in Move. 17 | - `escrow`: Basic object escrow module on Sui. 18 | - `escrow_shared`: Basic object escrow module with refunds and arbitration on Sui. 19 | - `i64`: Signed 64-bit integers. 20 | - `i128`: Signed 128-bit integers. 21 | - `linear_vesting`: Linear vesting of coins for a given beneficiary. 22 | - `math`: Standard math utilities missing in the Move language (for `u64`). 23 | - `math_safe_precise`: `mul_div` for `u64`s while avoiding overflow and a more precise `quadratic` function. 24 | - `math_u128`: Standard math utilities missing in the Move language (for `u128`). 25 | - `merkle_proof`: Merkle proof verification utilities. 26 | - `pseudorandom`: Pseudorandom number generator. 27 | - `to_string`: `u128` to `String` conversion utilities. 28 | - `vectors`: Vector utilities--specifically, comparison operators and a binary search function. 29 | - `object_box`: An implementation of ObjectBag that constrains bag to holding only one object. 30 | - `object_vec`: An implementation ObjectTable that does not require a generic for key and it uses indexing. 31 | 32 | ## Publishing 33 | 34 | ``` 35 | ./bin/publish.sh 36 | ``` 37 | 38 | If you get error _"Modules must all have 0x0 as their addresses."_ you first need to change the `originmate` in `Move.toml` to `0x0`. 39 | Then you can run the publish script again. 40 | This will yield a new address where the contract is deployed. 41 | We hard code the address to `Move.toml` in order for other packages to be able 42 | to use this package as a dependency. 43 | 44 | ## Usage 45 | 46 | Add following dependency to your `Move.toml`: 47 | 48 | ```toml 49 | [dependencies.Originmate] 50 | git = "https://github.com/Origin-Byte/originmate.git" 51 | rev = "<>" 52 | ``` 53 | -------------------------------------------------------------------------------- /contracts/originmate/sources/balances.move: -------------------------------------------------------------------------------- 1 | module originmate::balances { 2 | use std::type_name; 3 | use sui::balance::{Self, Balance}; 4 | use sui::dynamic_field as df; 5 | use sui::object::{Self, UID}; 6 | use sui::tx_context::TxContext; 7 | 8 | /// Stores balances of various currencies. 9 | struct Balances has store { 10 | /// Balances are stored as dynamic fields. 11 | inner: UID, 12 | /// How many balances are there associated with this struct. 13 | /// Can only be destroyed if the number is zero. 14 | items: u64, 15 | } 16 | 17 | public fun new(ctx: &mut TxContext): Balances { 18 | Balances { inner: object::new(ctx), items: 0 } 19 | } 20 | 21 | public fun destroy_empty(self: Balances) { 22 | let Balances { inner, items } = self; 23 | assert!(items == 0, 0); 24 | object::delete(inner); 25 | } 26 | 27 | public fun join_with(self: &mut Balances, with: Balance) { 28 | balance::join(borrow_mut(self), with); 29 | } 30 | 31 | public fun take_from(self: &mut Balances, from: &mut Balance, amount: u64) { 32 | balance::join(borrow_mut(self), balance::split(from, amount)); 33 | } 34 | 35 | public fun withdraw_all_from(self: &mut Balances, from: &mut Balance) { 36 | balance::join(borrow_mut(self), balance::withdraw_all(from)); 37 | } 38 | 39 | public fun withdraw_all(self: &mut Balances): Balance { 40 | self.items = self.items - 1; 41 | df::remove(&mut self.inner, type_name::get()) 42 | } 43 | 44 | public fun withdraw_amount(self: &mut Balances, amount: u64): Balance { 45 | balance::split(borrow_mut(self), amount) 46 | } 47 | 48 | /// If balance does no exist, it is created with zero value. 49 | public fun borrow_mut(self: &mut Balances): &mut Balance { 50 | let ft = type_name::get(); 51 | if (!df::exists_(&self.inner, ft)) { 52 | self.items = self.items + 1; 53 | df::add(&mut self.inner, ft, balance::zero()); 54 | }; 55 | df::borrow_mut(&mut self.inner, ft) 56 | } 57 | 58 | /// Panics if the balance does not exist. 59 | public fun borrow(self: &Balances): &Balance { 60 | df::borrow(&self.inner, type_name::get()) 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /contracts/originmate/sources/box.move: -------------------------------------------------------------------------------- 1 | /// @title box 2 | /// @notice Generalized box for transferring objects that only have `store` but not `key`. 3 | module originmate::box { 4 | use sui::object::{Self, UID}; 5 | use sui::transfer; 6 | use sui::tx_context::TxContext; 7 | 8 | struct Box has key, store { 9 | id: UID, 10 | obj: T 11 | } 12 | 13 | /// @dev Stores the sent object in an box object. 14 | /// @param recipient The destination address of the box object. 15 | public entry fun box(recipient: address, obj_in: T, ctx: &mut TxContext) { 16 | let box = Box { 17 | id: object::new(ctx), 18 | obj: obj_in 19 | }; 20 | transfer::public_transfer(box, recipient); 21 | } 22 | 23 | /// @dev Unboxes the object inside the box. 24 | public fun unbox(box: Box): T { 25 | let Box { 26 | id: id, 27 | obj: obj, 28 | } = box; 29 | object::delete(id); 30 | obj 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /contracts/originmate/sources/escrow.move: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | /// @title escrow 4 | /// @dev Basic escrow module: holds an object designated for a recipient until the sender approves withdrawal. 5 | module originmate::escrow { 6 | use sui::object::{Self, UID}; 7 | use sui::transfer; 8 | use sui::tx_context::TxContext; 9 | 10 | struct Escrow has key { 11 | id: UID, 12 | recipient: address, 13 | obj: T 14 | } 15 | 16 | /// @dev Stores the sent object in an escrow object. 17 | /// @param recipient The destination address of the escrowed object. 18 | public entry fun escrow(sender: address, recipient: address, obj_in: T, ctx: &mut TxContext) { 19 | let escrow = Escrow { 20 | id: object::new(ctx), 21 | recipient, 22 | obj: obj_in 23 | }; 24 | transfer::transfer(escrow, sender); 25 | } 26 | 27 | /// @dev Transfers escrowed object to the recipient. 28 | public entry fun transfer(escrow: Escrow) { 29 | let Escrow { 30 | id: info, 31 | recipient: recipient, 32 | obj: obj, 33 | } = escrow; 34 | object::delete(info); 35 | transfer::public_transfer(obj, recipient); 36 | } 37 | 38 | #[test_only] 39 | use sui::test_scenario; 40 | 41 | #[test_only] 42 | const TEST_SENDER_ADDR: address = @0xA11CE; 43 | 44 | #[test_only] 45 | const TEST_RECIPIENT_ADDR: address = @0xB0B; 46 | 47 | #[test_only] 48 | struct FakeObject has key, store { 49 | id: UID, 50 | data: u64 51 | } 52 | 53 | #[test] 54 | public fun test_end_to_end() { 55 | let scenario_wrapper = test_scenario::begin(TEST_SENDER_ADDR); 56 | let scenario = &mut scenario_wrapper; 57 | escrow(TEST_SENDER_ADDR, TEST_RECIPIENT_ADDR, FakeObject { id: object::new(test_scenario::ctx(scenario)), data: 1234 }, test_scenario::ctx(scenario)); 58 | test_scenario::next_tx(scenario, TEST_SENDER_ADDR); 59 | let escrow = test_scenario::take_from_sender>(scenario); 60 | transfer(escrow); 61 | test_scenario::next_tx(scenario, TEST_RECIPIENT_ADDR); 62 | let obj = test_scenario::take_from_sender(scenario); 63 | assert!(obj.data == 1234, 0); 64 | test_scenario::return_to_sender(scenario, obj); 65 | test_scenario::end(scenario_wrapper); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /contracts/originmate/sources/math_safe_precise.move: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | /// @title math_safe_precise 4 | /// @dev Overflow-avoidant and precise math utilities missing in the Move language (for `u64`). 5 | /// Specifically: 6 | /// 1) `mul_div` calculates `a * b / c` but converts to `u128`s during calculations to avoid overflow. 7 | /// 2) `quadratic` is the same as `math::quadratic` but uses `2**32` as a scalar instead of `2**16` for more precise math (converting to `u128`s during calculations for safety). 8 | module originmate::math_safe_precise { 9 | use originmate::math_u128; 10 | 11 | #[allow(unused_const)] 12 | const SCALAR: u64 = 1 << 32; 13 | const SCALAR_U128: u128 = 1 << 32; 14 | 15 | /// @notice Calculates `a * b / c` but converts to `u128`s for calculations to avoid overflow. 16 | public fun mul_div(a: u64, b: u64, c: u64): u64 { 17 | ((a as u128) * (b as u128) / (c as u128) as u64) 18 | } 19 | 20 | /// @notice Calculates `ax^2 + bx + c` assuming all variables are scaled by `2**32`. 21 | public fun quadratic(x: u64, a: u64, b: u64, c: u64): u64 { 22 | ( 23 | (math_u128::exp((x as u128), 2) / SCALAR_U128 * (a as u128) / SCALAR_U128) 24 | + ((b as u128) * (x as u128) / SCALAR_U128) 25 | + (c as u128) 26 | as u64) 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /contracts/originmate/sources/object_box.move: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | /// @title object_vec 4 | /// @dev An implementation of ObjectBag that constrains bag to holding only 5 | /// one object. 6 | module originmate::object_box { 7 | // TODO: Would be good to rename to ObjectField and create a second 8 | // Field which does not require key. Would allow users to mark dynamic 9 | // fields explicitly. 10 | // TODOS: Tests 11 | use std::type_name::{Self, TypeName}; 12 | 13 | use sui::dynamic_object_field as dof; 14 | use sui::object::{Self, UID}; 15 | use sui::tx_context::{TxContext}; 16 | 17 | /// @dev Attempting to add an object to an ObjectBox when it already has one. 18 | const EGenericBoxFull: u64 = 0; 19 | const ENotEmpty: u64 = 1; 20 | 21 | struct ObjectBox has key, store { 22 | id: UID, 23 | len: u64, 24 | } 25 | 26 | public fun empty(ctx: &mut TxContext): ObjectBox { 27 | ObjectBox { 28 | id: object::new(ctx), 29 | len: 0, 30 | } 31 | } 32 | 33 | public fun new( 34 | object: V, 35 | ctx: &mut TxContext, 36 | ): ObjectBox { 37 | 38 | let ob = ObjectBox { 39 | id: object::new(ctx), 40 | len: 0, 41 | }; 42 | 43 | dof::add( 44 | &mut ob.id, 45 | type_name::get(), 46 | object, 47 | ); 48 | 49 | ob.len = 1; 50 | ob 51 | } 52 | 53 | // === Domain Functions === 54 | 55 | public fun has_object(ob: &ObjectBox): bool { 56 | dof::exists_(&ob.id, type_name::get()) 57 | } 58 | 59 | public fun borrow(ob: &ObjectBox): &V { 60 | dof::borrow(&ob.id, type_name::get()) 61 | } 62 | 63 | public fun borrow_mut(ob: &mut ObjectBox): &mut V { 64 | dof::borrow_mut(&mut ob.id, type_name::get()) 65 | } 66 | 67 | public fun add( 68 | ob: &mut ObjectBox, 69 | v: V, 70 | ) { 71 | assert!(ob.len == 0, EGenericBoxFull); 72 | 73 | dof::add( 74 | &mut ob.id, 75 | type_name::get(), 76 | v, 77 | ); 78 | ob.len = ob.len + 1; 79 | } 80 | 81 | public fun remove( 82 | ob: &mut ObjectBox, 83 | ): V { 84 | ob.len = ob.len - 1; 85 | dof::remove(&mut ob.id, type_name::get()) 86 | } 87 | 88 | public fun is_empty(ob: &ObjectBox): bool { 89 | ob.len == 0 90 | } 91 | 92 | public fun destroy(ob: ObjectBox) { 93 | assert!(is_empty(&ob), ENotEmpty); 94 | 95 | let ObjectBox { id, len: _ } = ob; 96 | 97 | object::delete(id); 98 | } 99 | 100 | #[test_only] 101 | public fun destroy_for_testing(ob: ObjectBox) { 102 | let ObjectBox { id, len: _ } = ob; 103 | 104 | object::delete(id); 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /contracts/originmate/sources/typed_id.move: -------------------------------------------------------------------------------- 1 | // Copyright (c) Mysten Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | /// Typed wrappers around Sui object IDs 5 | /// While not always necessary, this is helpful for indicating the type of an object, particularly 6 | /// when storing its ID in another object. 7 | /// Additionally, it can be helpful for disambiguating between different IDs in an object. 8 | /// For example 9 | /// ``` 10 | /// struct MyObject has key { 11 | /// id: VersionedID, 12 | /// child1: TypedID, 13 | /// child2: TypedID, 14 | /// } 15 | /// ``` 16 | /// We then know that `child1` is an ID for an object of type `A` and that `child2` is an `ID` 17 | /// of an object of type `B` 18 | module originmate::typed_id { 19 | use sui::object::{Self, ID}; 20 | 21 | /// An ID of an of type `T`. See `ID` for more details 22 | /// By construction, it is guaranteed that the `ID` represents an object of type `T` 23 | struct TypedID has copy, drop, store { 24 | id: ID, 25 | } 26 | 27 | /// Get the underlying `ID` of `obj`, and remember the type 28 | public fun new(obj: &T): TypedID { 29 | TypedID { id: object::id(obj) } 30 | } 31 | 32 | /// Borrow the inner `ID` of `typed_id` 33 | public fun as_id(typed_id: &TypedID): &ID { 34 | &typed_id.id 35 | } 36 | 37 | /// Get the inner `ID` of `typed_id` 38 | public fun to_id(typed_id: TypedID): ID { 39 | let TypedID { id } = typed_id; 40 | id 41 | } 42 | 43 | /// Check that underlying `ID` in the `typed_id` equals the objects ID 44 | public fun equals_object(typed_id: &TypedID, obj: &T): bool { 45 | typed_id.id == object::id(obj) 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /contracts/permissions/Move.lock: -------------------------------------------------------------------------------- 1 | # @generated by Move, please check-in and do not edit manually. 2 | 3 | [move] 4 | version = 0 5 | manifest_digest = "60B441198F70B8079B0D9C305F39BF9577EFE8B656000E994D7439E0C5BF1A9F" 6 | deps_digest = "3C4103934B1E040BB6B23F1D610B4EF9F2F1166A50A104EADCF77467C004C600" 7 | 8 | dependencies = [ 9 | { name = "Sui" }, 10 | { name = "Utils" }, 11 | ] 12 | 13 | [[move.package]] 14 | name = "MoveStdlib" 15 | source = { git = "https://github.com/MystenLabs/sui.git", rev = "mainnet-v1.19.1", subdir = "crates/sui-framework/packages/move-stdlib" } 16 | 17 | [[move.package]] 18 | name = "Pseudorandom" 19 | source = { local = "../pseudorandom" } 20 | 21 | dependencies = [ 22 | { name = "Sui" }, 23 | ] 24 | 25 | [[move.package]] 26 | name = "Sui" 27 | source = { git = "https://github.com/MystenLabs/sui.git", rev = "mainnet-v1.19.1", subdir = "crates/sui-framework/packages/sui-framework" } 28 | 29 | dependencies = [ 30 | { name = "MoveStdlib" }, 31 | ] 32 | 33 | [[move.package]] 34 | name = "Utils" 35 | source = { local = "../utils" } 36 | 37 | dependencies = [ 38 | { name = "Pseudorandom" }, 39 | { name = "Sui" }, 40 | ] 41 | -------------------------------------------------------------------------------- /contracts/permissions/Move.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "Permissions" 3 | version = "1.7.0" 4 | published-at = "0xe571741e4b123a32e4afda5268735a87f7ae5bc1a945d53c2c160d161651c7fc" 5 | 6 | [dependencies] 7 | Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "mainnet-v1.19.1" } 8 | Utils = { local = "./../utils" } 9 | 10 | [addresses] 11 | ob_permissions = "0x16c5f17f2d55584a6e6daa442ccf83b4530d10546a8e7dedda9ba324e012fc40" 12 | -------------------------------------------------------------------------------- /contracts/permissions/sources/init.move: -------------------------------------------------------------------------------- 1 | module ob_permissions::permissions { 2 | use sui::package; 3 | use sui::transfer; 4 | use sui::tx_context::{Self, TxContext}; 5 | 6 | struct PERMISSIONS has drop {} 7 | 8 | #[allow(unused_function)] 9 | fun init(otw: PERMISSIONS, ctx: &mut TxContext) { 10 | let pub = package::claim(otw, ctx); 11 | transfer::public_transfer(pub, tx_context::sender(ctx)); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /contracts/permissions/sources/permissions/witness.move: -------------------------------------------------------------------------------- 1 | /// Module of the `WitnessGenerator` used for generating authenticating 2 | /// witnesses on demand. 3 | /// 4 | /// The OriginByte protocol leverages on a Delegated-Witness pattern which function 5 | /// as an hybrid between the Witness and Publisher pattern. Furthermore, it provides 6 | /// a `WitnessGenerator` which allows for the witness creation to be delegated to 7 | /// other smart contracts/objects defined in modules other than the creator of `T`. 8 | /// In a nutshell, the differences between a Delegated-Witness and a typical Witness are: 9 | /// 10 | /// - Deletaged-Witness has copy and it can therefore be easily propated accross 11 | /// a stack of function calls; 12 | /// - Deletaged-Witness is typed, and this in conjunction with the copy ability allows for the 13 | /// reduction of type-reflected assertions that are required to be perfomed accross the call stack 14 | /// - A Delegated-Witness can be created by `Witness {}`, so like the witness its access can be 15 | /// designed by the smart contract that defines `T`; 16 | /// - It can also be created directly through the Publisher object; 17 | /// - It can be generated by a generator object `WitnessGenerator` which has store ability, 18 | /// therefore allowing for witness-creation process to be more flexibly delegated. 19 | module ob_permissions::witness { 20 | use sui::package::Publisher; 21 | 22 | use ob_utils::utils; 23 | 24 | /// Collection witness generator 25 | struct WitnessGenerator has store {} 26 | 27 | /// Delegated witness of a generic type. The type `T` can either be 28 | /// the One-Time Witness of a collection or the type of an NFT itself. 29 | struct Witness has copy, drop {} 30 | 31 | /// Create a new `WitnessGenerator` from witness 32 | public fun generator(witness: W): WitnessGenerator { 33 | generator_delegated(from_witness(witness)) 34 | } 35 | 36 | /// Create a new `WitnessGenerator` from delegated witness 37 | public fun generator_delegated( 38 | _witness: Witness, 39 | ): WitnessGenerator { 40 | WitnessGenerator {} 41 | } 42 | 43 | /// Delegate a delegated witness from arbitrary witness type 44 | public fun from_witness(_witness: W): Witness { 45 | utils::assert_same_module_as_witness(); 46 | Witness {} 47 | } 48 | 49 | /// Creates a delegated witness from a package publisher. 50 | /// Useful for contracts which don't support our protocol the easy way, 51 | /// but use the standard of publisher. 52 | public fun from_publisher(publisher: &Publisher): Witness { 53 | utils::assert_publisher(publisher); 54 | Witness {} 55 | } 56 | 57 | /// Delegate a collection generic witness 58 | public fun delegate(_generator: &WitnessGenerator): Witness { 59 | Witness {} 60 | } 61 | 62 | // === Test-Only Functions === 63 | 64 | #[test_only] 65 | public fun test_dw(): Witness { 66 | Witness {} 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /contracts/permissions/sources/pub.move: -------------------------------------------------------------------------------- 1 | module ob_permissions::frozen_pub { 2 | use sui::tx_context::TxContext; 3 | 4 | use ob_permissions::frozen_publisher; 5 | 6 | struct FROZEN_PUB has drop {} 7 | 8 | #[allow(unused_function)] 9 | fun init(otw: FROZEN_PUB, ctx: &mut TxContext) { 10 | frozen_publisher::freeze_from_otw(otw, ctx); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /contracts/permissions/tests/witness.move: -------------------------------------------------------------------------------- 1 | #[test_only] 2 | module ob_permissions::test_witness { 3 | use std::string; 4 | 5 | use sui::test_utils as sui_utils; 6 | use sui::package; 7 | use sui::transfer; 8 | 9 | use ob_utils::utils; 10 | use ob_permissions::witness; 11 | use ob_permissions::test_foo; 12 | use sui::test_scenario::{Self, ctx}; 13 | 14 | struct Witness has drop {} 15 | struct Witness2 has drop {} 16 | struct TEST_WITNESS has drop {} 17 | struct ASSERT_SAME_MODULE_AS_WITNESS has drop {} 18 | 19 | struct Foo has store {} 20 | 21 | #[test] 22 | fun get_dw_from_wit() { 23 | witness::from_witness(Witness {}); 24 | } 25 | 26 | #[test] 27 | fun get_dw_from_publisher() { 28 | let scenario = test_scenario::begin(@0x0); 29 | 30 | let otw = sui_utils::create_one_time_witness(); 31 | let pub = package::claim(otw, ctx(&mut scenario)); 32 | witness::from_publisher(&pub); 33 | 34 | transfer::public_transfer(pub, @0x0); 35 | 36 | test_scenario::end(scenario); 37 | } 38 | 39 | #[test] 40 | public fun it_returns_package_module_type() { 41 | let (package_addr, module_name, type_name) = utils::get_package_module_type(); 42 | 43 | // We can only test the length of the package address, since the address 44 | // itself depends on the deployed version. An example of an address would be: 45 | // 22122de69059b544f3c5f35ce78854a9b926fa0d 46 | 47 | assert!(string::length(&package_addr) == 64, 0); 48 | assert!(module_name == string::utf8(b"test_witness"), 0); 49 | assert!(type_name == string::utf8(b"Witness"), 0); 50 | } 51 | 52 | #[test] 53 | public fun it_works() { 54 | utils::assert_same_module_as_witness(); 55 | } 56 | 57 | #[test] 58 | public fun it_works_for_another_module() { 59 | utils::assert_same_module_as_witness(); 60 | } 61 | 62 | #[test] 63 | #[expected_failure(abort_code = ob_utils::utils::EInvalidWitnessModule)] 64 | public fun it_must_same_module() { 65 | utils::assert_same_module_as_witness(); 66 | } 67 | 68 | #[test] 69 | #[expected_failure(abort_code = ob_utils::utils::EInvalidWitness)] 70 | public fun it_must_be_witness() { 71 | utils::assert_same_module_as_witness(); 72 | } 73 | } 74 | 75 | #[test_only] 76 | module ob_permissions::test_foo { 77 | struct Witness has drop {} 78 | struct Witness2 has drop {} 79 | struct TEST_FOO has drop {} 80 | } 81 | -------------------------------------------------------------------------------- /contracts/pseudorandom/Move.lock: -------------------------------------------------------------------------------- 1 | # @generated by Move, please check-in and do not edit manually. 2 | 3 | [move] 4 | version = 0 5 | manifest_digest = "A25AEF3E93F4698F1B421C5F7C7E8BF3CD1FE83D2359335572EE102F7B1C97E3" 6 | deps_digest = "F8BBB0CCB2491CA29A3DF03D6F92277A4F3574266507ACD77214D37ECA3F3082" 7 | 8 | dependencies = [ 9 | { name = "Sui" }, 10 | ] 11 | 12 | [[move.package]] 13 | name = "MoveStdlib" 14 | source = { git = "https://github.com/MystenLabs/sui.git", rev = "mainnet-v1.19.1", subdir = "crates/sui-framework/packages/move-stdlib" } 15 | 16 | [[move.package]] 17 | name = "Sui" 18 | source = { git = "https://github.com/MystenLabs/sui.git", rev = "mainnet-v1.19.1", subdir = "crates/sui-framework/packages/sui-framework" } 19 | 20 | dependencies = [ 21 | { name = "MoveStdlib" }, 22 | ] 23 | -------------------------------------------------------------------------------- /contracts/pseudorandom/Move.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "Pseudorandom" 3 | version = "1.7.0" 4 | published-at = "0x96151d14878707d390b370b70843704cc4606209883d3ea3a4e5cf8ac2872be2" 5 | 6 | [dependencies] 7 | Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "mainnet-v1.19.1" } 8 | 9 | [addresses] 10 | ob_pseudorandom = "0x9e5962d5183664be8a7762fbe94eee6e3457c0cc701750c94c17f7f8ac5a32fb" 11 | -------------------------------------------------------------------------------- /contracts/request/Move.lock: -------------------------------------------------------------------------------- 1 | # @generated by Move, please check-in and do not edit manually. 2 | 3 | [move] 4 | version = 0 5 | manifest_digest = "BD394B80D3A815832432D48728C11D916AD2AD9A2F30B1B8F8189BD8374CAC0A" 6 | deps_digest = "3C4103934B1E040BB6B23F1D610B4EF9F2F1166A50A104EADCF77467C004C600" 7 | 8 | dependencies = [ 9 | { name = "Permissions" }, 10 | { name = "Sui" }, 11 | ] 12 | 13 | [[move.package]] 14 | name = "MoveStdlib" 15 | source = { git = "https://github.com/MystenLabs/sui.git", rev = "mainnet-v1.19.1", subdir = "crates/sui-framework/packages/move-stdlib" } 16 | 17 | [[move.package]] 18 | name = "Permissions" 19 | source = { local = "../permissions" } 20 | 21 | dependencies = [ 22 | { name = "Sui" }, 23 | { name = "Utils" }, 24 | ] 25 | 26 | [[move.package]] 27 | name = "Pseudorandom" 28 | source = { local = "../pseudorandom" } 29 | 30 | dependencies = [ 31 | { name = "Sui" }, 32 | ] 33 | 34 | [[move.package]] 35 | name = "Sui" 36 | source = { git = "https://github.com/MystenLabs/sui.git", rev = "mainnet-v1.19.1", subdir = "crates/sui-framework/packages/sui-framework" } 37 | 38 | dependencies = [ 39 | { name = "MoveStdlib" }, 40 | ] 41 | 42 | [[move.package]] 43 | name = "Utils" 44 | source = { local = "../utils" } 45 | 46 | dependencies = [ 47 | { name = "Pseudorandom" }, 48 | { name = "Sui" }, 49 | ] 50 | -------------------------------------------------------------------------------- /contracts/request/Move.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "Request" 3 | version = "1.7.0" 4 | published-at = "0xd4e94a458e5d192ffbac8364339e926450391bb8bd248973087f8cc264da3258" 5 | 6 | [dependencies] 7 | Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "mainnet-v1.19.1" } 8 | Permissions = { local = "./../permissions" } 9 | 10 | [addresses] 11 | ob_request = "0xe2c7a6843cb13d9549a9d2dc1c266b572ead0b4b9f090e7c3c46de2714102b43" 12 | -------------------------------------------------------------------------------- /contracts/request/sources/init.move: -------------------------------------------------------------------------------- 1 | module ob_request::ob_request { 2 | use sui::package; 3 | use sui::transfer; 4 | use sui::tx_context::{Self, TxContext}; 5 | 6 | struct OB_REQUEST has drop {} 7 | 8 | #[allow(unused_function)] 9 | fun init(otw: OB_REQUEST, ctx: &mut TxContext) { 10 | let pub = package::claim(otw, ctx); 11 | transfer::public_transfer(pub, tx_context::sender(ctx)); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /contracts/request/sources/pub.move: -------------------------------------------------------------------------------- 1 | module ob_request::frozen_pub { 2 | use sui::tx_context::TxContext; 3 | 4 | use ob_permissions::frozen_publisher; 5 | 6 | struct FROZEN_PUB has drop {} 7 | 8 | #[allow(unused_function)] 9 | fun init(otw: FROZEN_PUB, ctx: &mut TxContext) { 10 | frozen_publisher::freeze_from_otw(otw, ctx); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /contracts/request/sources/request/policies/withdraw.move: -------------------------------------------------------------------------------- 1 | /// Withdraw Policy/Request controls how NFTs can be withdrawn from the OB Kiosk 2 | /// or any other NFT container that implements it. 3 | module ob_request::withdraw_request { 4 | use sui::package::Publisher; 5 | use sui::tx_context::TxContext; 6 | 7 | use ob_request::request::{Self, RequestBody, Policy, PolicyCap, WithNft}; 8 | 9 | 10 | // === Structs === 11 | 12 | struct Witness has drop {} 13 | struct WITHDRAW_REQ has drop {} 14 | 15 | struct WithdrawRequest { 16 | sender: address, 17 | inner: RequestBody>, 18 | } 19 | 20 | // === Fns === 21 | 22 | public fun new( 23 | sender: address, 24 | ctx: &mut TxContext, 25 | ): WithdrawRequest { 26 | WithdrawRequest { 27 | sender, 28 | inner: request::new(ctx), 29 | } 30 | } 31 | 32 | public fun init_policy(publisher: &Publisher, ctx: &mut TxContext): (Policy>, PolicyCap) { 33 | request::new_policy_with_type(WITHDRAW_REQ {}, publisher, ctx) 34 | } 35 | 36 | /// Adds a `Receipt` to the `Request`, unblocking the request and 37 | /// confirming that the policy requirements are satisfied. 38 | public fun add_receipt(self: &mut WithdrawRequest, rule: &Rule) { 39 | request::add_receipt(&mut self.inner, rule); 40 | } 41 | 42 | public fun inner_mut( 43 | self: &mut WithdrawRequest 44 | ): &mut RequestBody> { &mut self.inner } 45 | 46 | public fun confirm(self: WithdrawRequest, policy: &Policy>) { 47 | let WithdrawRequest { 48 | sender: _, 49 | inner, 50 | } = self; 51 | 52 | request::confirm(inner, policy); 53 | } 54 | 55 | public fun tx_sender(self: &WithdrawRequest): address { self.sender } 56 | } 57 | -------------------------------------------------------------------------------- /contracts/tests/Move.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "IntegrationTests" 3 | version = "1.7.0" 4 | published-at = "0x" 5 | 6 | [dependencies] 7 | Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "mainnet-v1.19.1" } 8 | Originmate = { local = "./../originmate" } 9 | Critbit = { local = "./../critbit" } 10 | Permissions = { local = "./../permissions" } 11 | Authlist = { local = "./../authlist" } 12 | Allowlist = { local = "./../allowlist" } 13 | Request = { local = "./../request" } 14 | Kiosk = { local = "./../kiosk" } 15 | LiquidityLayerV1 = { local = "./../liquidity_layer_v1" } 16 | NftProtocol = { local = "./../nft_protocol" } 17 | 18 | [addresses] 19 | ob_tests = "0x" 20 | -------------------------------------------------------------------------------- /contracts/tests/sources/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Origin-Byte/nft-protocol/e8e8efd77ab15d7b2cf30958fd748dbb3afbdaab/contracts/tests/sources/.gitkeep -------------------------------------------------------------------------------- /contracts/tests/tests/domains/creators.move: -------------------------------------------------------------------------------- 1 | #[test_only] 2 | #[lint_allow(share_owned)] 3 | module ob_tests::test_creators { 4 | use sui::transfer; 5 | use sui::vec_set; 6 | use sui::test_scenario::{Self, ctx}; 7 | 8 | use ob_permissions::witness; 9 | use nft_protocol::creators::{Self, Creators}; 10 | use nft_protocol::collection::{Self, Collection}; 11 | 12 | struct Foo {} 13 | struct Witness has drop {} 14 | 15 | const CREATOR: address = @0xA1C04; 16 | 17 | #[test] 18 | fun add_attribution() { 19 | let scenario = test_scenario::begin(CREATOR); 20 | 21 | let delegated_witness = witness::from_witness(Witness {}); 22 | 23 | let collection: Collection = collection::create( 24 | delegated_witness, ctx(&mut scenario), 25 | ); 26 | 27 | collection::add_domain( 28 | delegated_witness, 29 | &mut collection, 30 | creators::new(vec_set::singleton(CREATOR)), 31 | ); 32 | 33 | collection::assert_domain(&collection); 34 | 35 | transfer::public_share_object(collection); 36 | 37 | test_scenario::end(scenario); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /contracts/tests/tests/domains/royalty.move: -------------------------------------------------------------------------------- 1 | #[test_only] 2 | #[lint_allow(share_owned)] 3 | module ob_tests::test_royalty { 4 | use sui::transfer; 5 | use sui::test_scenario::{Self, ctx}; 6 | 7 | use nft_protocol::collection::{Self, Collection}; 8 | use ob_permissions::witness; 9 | use nft_protocol::royalty_strategy_bps; 10 | use nft_protocol::royalty::{Self, RoyaltyDomain}; 11 | 12 | struct Foo has drop {} 13 | struct Witness has drop {} 14 | 15 | const CREATOR: address = @0xA1C04; 16 | 17 | #[test] 18 | fun add_royalty() { 19 | let scenario = test_scenario::begin(CREATOR); 20 | 21 | let delegated_witness = witness::from_witness(Witness {}); 22 | 23 | let collection: Collection = collection::create( 24 | delegated_witness, ctx(&mut scenario), 25 | ); 26 | 27 | let royalty_domain = royalty::from_address(CREATOR, ctx(&mut scenario)); 28 | 29 | royalty_strategy_bps::create_domain_and_add_strategy( 30 | delegated_witness, &mut collection, royalty_domain, 100, ctx(&mut scenario), 31 | ); 32 | 33 | collection::assert_domain(&collection); 34 | 35 | transfer::public_share_object(collection); 36 | 37 | test_scenario::end(scenario); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /contracts/tests/tests/domains/tags.move: -------------------------------------------------------------------------------- 1 | #[test_only] 2 | #[lint_allow(share_owned)] 3 | module ob_tests::test_tags { 4 | use std::string; 5 | use sui::transfer; 6 | use sui::package; 7 | use sui::display; 8 | use sui::test_scenario::{Self, ctx}; 9 | use sui::object::UID; 10 | 11 | use nft_protocol::tags; 12 | use ob_utils::display as ob_display; 13 | 14 | struct Foo has key, store { 15 | id: UID, 16 | } 17 | 18 | struct TEST_TAGS has drop {} 19 | 20 | const CREATOR: address = @0xA1C04; 21 | 22 | #[test] 23 | fun add_nft_tags() { 24 | let scenario = test_scenario::begin(CREATOR); 25 | let publisher = package::test_claim(TEST_TAGS {}, ctx(&mut scenario)); 26 | 27 | let tags = vector[tags::art(), tags::collectible()]; 28 | 29 | let display = display::new(&publisher, ctx(&mut scenario)); 30 | display::add(&mut display, string::utf8(b"tags"), ob_display::from_vec(tags)); 31 | display::update_version(&mut display); 32 | 33 | let fields = display::fields(&display); 34 | let fields_str = ob_display::from_vec_map_ref(fields, false); 35 | 36 | assert!(fields_str == string::utf8(b"{\"tags\": [\"Art\",\"Collectible\"]}"), 0); 37 | 38 | transfer::public_transfer(display, CREATOR); 39 | transfer::public_transfer(publisher, CREATOR); 40 | 41 | test_scenario::end(scenario); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /contracts/tests/tests/frozen_publisher.move: -------------------------------------------------------------------------------- 1 | #[test_only] 2 | #[lint_allow(share_owned)] 3 | module ob_tests::test_frozen_publisher { 4 | use std::string; 5 | 6 | use sui::transfer; 7 | use sui::display; 8 | use sui::object; 9 | use sui::test_utils as sui_tests; 10 | use sui::test_scenario::{Self, ctx}; 11 | 12 | use nft_protocol::collection::{Self, Collection}; 13 | use ob_permissions::frozen_publisher; 14 | use nft_protocol::tags; 15 | use nft_protocol::mint_cap; 16 | use nft_protocol::nft_protocol::NFT_PROTOCOL; 17 | use ob_utils::display::{Self as ob_display}; 18 | use ob_permissions::witness; 19 | 20 | use ob_tests::test_utils::{Foo, TEST_UTILS, creator}; 21 | 22 | #[test] 23 | fun create_collection_display_with_frozen_pub() { 24 | let scenario = test_scenario::begin(creator()); 25 | 26 | let delegated_witness = witness::test_dw(); 27 | 28 | let collection: Collection = collection::create( 29 | delegated_witness, ctx(&mut scenario), 30 | ); 31 | 32 | let tags = vector[tags::art(), tags::collectible()]; 33 | 34 | let otw = sui_tests::create_one_time_witness(); 35 | let frozen_pub = frozen_publisher::get_frozen_publisher_for_test(otw, ctx(&mut scenario)); 36 | 37 | let display = collection::new_display( 38 | delegated_witness, 39 | &frozen_pub, 40 | ctx(&mut scenario), 41 | ); 42 | 43 | display::add(&mut display, string::utf8(b"collection_name"), string::utf8(b"Foo")); 44 | display::add(&mut display, string::utf8(b"tags"), ob_display::from_vec(tags)); 45 | 46 | display::update_version(&mut display); 47 | transfer::public_transfer(display, creator()); 48 | 49 | frozen_publisher::public_freeze_object(frozen_pub); 50 | transfer::public_share_object(collection); 51 | test_scenario::end(scenario); 52 | } 53 | 54 | #[test] 55 | fun create_mint_cap_display_with_frozen_pub() { 56 | let scenario = test_scenario::begin(creator()); 57 | 58 | let delegated_witness = witness::test_dw(); 59 | 60 | let otw = sui_tests::create_one_time_witness(); 61 | 62 | let mint_cap = mint_cap::new_unlimited( 63 | &otw, object::id_from_address(@0x0), ctx(&mut scenario), 64 | ); 65 | 66 | let otw = sui_tests::create_one_time_witness(); 67 | let frozen_pub = frozen_publisher::get_frozen_publisher_for_test(otw, ctx(&mut scenario)); 68 | 69 | let display = mint_cap::new_display( 70 | delegated_witness, 71 | &frozen_pub, 72 | ctx(&mut scenario), 73 | ); 74 | 75 | display::add(&mut display, string::utf8(b"collection_name"), string::utf8(b"Foo")); 76 | display::add(&mut display, string::utf8(b"supply"), string::utf8(b"{supply}")); 77 | display::update_version(&mut display); 78 | transfer::public_transfer(display, creator()); 79 | 80 | frozen_publisher::public_freeze_object(frozen_pub); 81 | 82 | transfer::public_transfer(mint_cap, @0x0); 83 | test_scenario::end(scenario); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /contracts/tests/tests/mint_event.move: -------------------------------------------------------------------------------- 1 | #[test_only] 2 | #[lint_allow(share_owned)] 3 | module ob_tests::test_mint_event { 4 | use sui::object::{Self, UID}; 5 | use sui::transfer; 6 | use sui::test_scenario::{Self, ctx}; 7 | 8 | use nft_protocol::mint_event; 9 | use ob_permissions::witness; 10 | 11 | struct Foo has key, store { 12 | id: UID, 13 | } 14 | 15 | struct Witness has drop {} 16 | 17 | const CREATOR: address = @0xA1C05; 18 | 19 | #[test] 20 | #[expected_failure(abort_code = mint_event::EInvalidBurnGuard)] 21 | fun try_burn() { 22 | let scenario = test_scenario::begin(CREATOR); 23 | 24 | let collection = object::new(ctx(&mut scenario)); 25 | let collection_id = object::uid_to_inner(&collection); 26 | 27 | let delegated_witness = 28 | witness::from_witness(Witness {}); 29 | 30 | let nft = Foo { id: object::new(ctx(&mut scenario)) }; 31 | 32 | let guard = mint_event::start_burn(delegated_witness, &nft); 33 | 34 | let fake_id = object::new(ctx(&mut scenario)); 35 | mint_event::emit_burn(guard, collection_id, fake_id); 36 | 37 | let Foo { id } = nft; 38 | object::delete(id); 39 | object::delete(collection); 40 | test_scenario::end(scenario); 41 | } 42 | 43 | #[test] 44 | fun test_events() { 45 | let scenario = test_scenario::begin(CREATOR); 46 | 47 | let collection = object::new(ctx(&mut scenario)); 48 | let collection_id = object::uid_to_inner(&collection); 49 | 50 | let delegated_witness = 51 | witness::from_witness(Witness {}); 52 | 53 | let nft = Foo { id: object::new(ctx(&mut scenario)) }; 54 | mint_event::emit_mint(delegated_witness, collection_id, &nft); 55 | 56 | transfer::public_transfer(nft, CREATOR); 57 | test_scenario::next_tx(&mut scenario, CREATOR); 58 | 59 | let nft = test_scenario::take_from_address( 60 | &scenario, CREATOR, 61 | ); 62 | 63 | let guard = mint_event::start_burn(delegated_witness, &nft); 64 | let Foo { id } = nft; 65 | 66 | mint_event::emit_burn(guard, collection_id, id); 67 | 68 | object::delete(collection); 69 | test_scenario::end(scenario); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /contracts/tests/tests/misc.move: -------------------------------------------------------------------------------- 1 | #[test_only] 2 | #[lint_allow(share_owned)] 3 | module ob_tests::misc { 4 | use sui::test_scenario::{Self, ctx}; 5 | use sui::object::{Self, UID}; 6 | use sui::transfer; 7 | use ob_tests::test_utils::creator; 8 | 9 | struct HotPotato {} 10 | 11 | struct HotPotatoWrapper { 12 | potato: HotPotato 13 | } 14 | 15 | struct Signer has key, store { 16 | id: UID, 17 | transfer_signer: UID, 18 | } 19 | 20 | fun delete_potato_wrapper(wrapper: HotPotatoWrapper): HotPotato { 21 | let HotPotatoWrapper { 22 | potato, 23 | } = wrapper; 24 | 25 | potato 26 | } 27 | 28 | fun delete_potato(potato: HotPotato) { 29 | let HotPotato {} = potato; 30 | } 31 | 32 | #[test] 33 | fun try_wrap_potato() { 34 | let scenario = test_scenario::begin(creator()); 35 | 36 | let potato_wrapper = HotPotatoWrapper { 37 | potato: HotPotato {}, 38 | }; 39 | 40 | let potato = delete_potato_wrapper(potato_wrapper); 41 | 42 | delete_potato(potato); 43 | 44 | test_scenario::end(scenario); 45 | } 46 | 47 | #[test] 48 | fun migrate_signer() { 49 | let scenario = test_scenario::begin(creator()); 50 | let signer_1 = Signer { 51 | id: object::new(ctx(&mut scenario)), 52 | transfer_signer: object::new(ctx(&mut scenario)), 53 | }; 54 | 55 | transfer::public_transfer(signer_1, creator()); 56 | 57 | test_scenario::next_tx(&mut scenario, creator()); 58 | 59 | let signer_1 = 60 | test_scenario::take_from_address(&scenario, creator()); 61 | 62 | let Signer { id, transfer_signer } = signer_1; 63 | object::delete(id); 64 | 65 | let signer_2 = Signer { 66 | id: object::new(ctx(&mut scenario)), 67 | transfer_signer 68 | }; 69 | 70 | test_scenario::next_tx(&mut scenario, creator()); 71 | 72 | let Signer { id, transfer_signer } = signer_2; 73 | object::delete(id); 74 | object::delete(transfer_signer); 75 | 76 | test_scenario::end(scenario); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /contracts/tests/tests/publisher.move: -------------------------------------------------------------------------------- 1 | #[test_only] 2 | module ob_tests::new_types { 3 | struct Ar15 has drop {} 4 | struct Mp40 has drop {} 5 | 6 | } 7 | 8 | #[test_only] 9 | module ob_tests::publisher_type { 10 | use ob_tests::new_types::Ar15; 11 | 12 | use sui::object::UID; 13 | use sui::sui::SUI; 14 | use std::type_name; 15 | 16 | #[allow(unused_field)] 17 | struct Gun has key, store { 18 | id: UID, 19 | } 20 | 21 | #[test] 22 | fun check_different_types_with_wrapper() { 23 | let type_ar = type_name::get>(); 24 | let type_sui = type_name::get>(); 25 | 26 | // We assert that the address generated from the type_name is the 27 | // address of the outer type. We therefore can plugin inner types 28 | // of different packagent and maintain and use the Publisher object of 29 | // the outer type. 30 | let addr_ar = type_name::get_address(&type_ar); 31 | let addr_sui = type_name::get_address(&type_sui); 32 | 33 | assert!(addr_ar == addr_sui, 0); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /contracts/tests/tests/utils/utils.from_vec_to_map.move: -------------------------------------------------------------------------------- 1 | #[test_only] 2 | module ob_tests::utils_from_vec_to_map { 3 | use std::ascii; 4 | use std::ascii::String; 5 | use std::vector; 6 | use sui::vec_map::{Self}; 7 | use ob_utils::utils::{Self}; 8 | 9 | #[test] 10 | public fun test_from_vec_to_map_empty_vectors() { 11 | let keys: vector = vector::empty(); 12 | let values: vector = vector::empty(); 13 | let m = utils::from_vec_to_map(keys, values); 14 | assert!(vec_map::is_empty(&m), 0); 15 | } 16 | 17 | #[test] 18 | public fun test_from_vec_to_map_single_entry() { 19 | let keys: vector = vector[1]; 20 | let values: vector = vector[ascii::string(b"zero")]; 21 | let m = utils::from_vec_to_map(keys, values); 22 | assert!(vec_map::size(&m) == 1, 0); 23 | assert!(*vec_map::get(&m, &1) == ascii::string(b"zero"), 1); 24 | } 25 | 26 | #[test] 27 | public fun test_from_vec_to_map_multiple_entries() { 28 | let keys: vector = vector[1, 2, 3]; 29 | let values: vector = vector[ascii::string(b"one"), ascii::string(b"two"), ascii::string(b"three")]; 30 | let m = utils::from_vec_to_map(keys, values); 31 | assert!(vec_map::size(&m) == 3, 0); 32 | assert!(*vec_map::get(&m, &1) == ascii::string(b"one"), 1); 33 | assert!(*vec_map::get(&m, &2) == ascii::string(b"two"), 2); 34 | assert!(*vec_map::get(&m, &3) == ascii::string(b"three"), 3); 35 | } 36 | 37 | #[test] 38 | public fun test_from_vec_to_map_non_contiguous_keys() { 39 | let keys: vector = vector[1, 3, 5]; 40 | let values: vector = vector[ascii::string(b"one"), ascii::string(b"three"), ascii::string(b"five")]; 41 | let m = utils::from_vec_to_map(keys, values); 42 | assert!(vec_map::size(&m) == 3, 0); 43 | assert!(*vec_map::get(&m, &1) == ascii::string(b"one"), 1); 44 | assert!(*vec_map::get(&m, &3) == ascii::string(b"three"), 2); 45 | assert!(*vec_map::get(&m, &5) == ascii::string(b"five"), 3); 46 | } 47 | 48 | #[test] 49 | #[expected_failure(abort_code = utils::EMismatchedKeyValueLength)] 50 | public fun test_from_vec_to_map_mismatched_key_value_len() { 51 | let keys: vector = vector[1, 2]; 52 | let values: vector = vector[ascii::string(b"one"), ascii::string(b"two"), ascii::string(b"three")]; 53 | let _m = utils::from_vec_to_map(keys, values); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /contracts/tests/tests/utils/utils.insert_vec_in_table.move: -------------------------------------------------------------------------------- 1 | #[test_only] 2 | module ob_tests::utils_insert_vec_in_table { 3 | use std::vector; 4 | use ob_utils::utils::{Self}; 5 | use sui::table_vec::{Self}; 6 | use sui::test_scenario as ts; 7 | 8 | const TEST_UTILS: address = @0x123; 9 | 10 | #[test] 11 | public fun test_insert_vec_in_table_empty_vector() { 12 | let scenario = ts::begin(TEST_UTILS); 13 | let table_vec = table_vec::empty(ts::ctx(&mut scenario)); 14 | let v: vector = vector::empty(); 15 | 16 | utils::insert_vec_in_table(&mut table_vec, v); 17 | 18 | assert!(table_vec::length(&table_vec) == 0, 0); 19 | table_vec::destroy_empty(table_vec); 20 | ts::end(scenario); 21 | } 22 | 23 | #[test] 24 | public fun test_insert_vec_in_table_single_entry() { 25 | let scenario = ts::begin(TEST_UTILS); 26 | let table_vec = table_vec::empty(ts::ctx(&mut scenario)); 27 | let v: vector = vector[5]; 28 | 29 | utils::insert_vec_in_table(&mut table_vec, v); 30 | 31 | assert!(table_vec::length(&table_vec) == 1, 0); 32 | let value = table_vec::borrow(&table_vec, 0); 33 | assert!(*value == 5, 1); 34 | 35 | table_vec::pop_back(&mut table_vec); 36 | table_vec::destroy_empty(table_vec); 37 | ts::end(scenario); 38 | } 39 | 40 | #[test] 41 | public fun test_insert_vec_in_table_multiple_entries() { 42 | let scenario = ts::begin(TEST_UTILS); 43 | let table_vec = table_vec::empty(ts::ctx(&mut scenario)); 44 | let v: vector = vector[1, 2, 3]; 45 | 46 | utils::insert_vec_in_table(&mut table_vec, v); 47 | 48 | assert!(table_vec::length(&table_vec) == 3, 0); 49 | let value1 = table_vec::borrow(&table_vec, 0); 50 | assert!(*value1 == 3, 1); 51 | 52 | let value2 = table_vec::borrow(&table_vec, 1); 53 | assert!(*value2 == 2, 2); 54 | 55 | let value3 = table_vec::borrow(&table_vec, 2); 56 | assert!(*value3 == 1, 3); 57 | 58 | table_vec::pop_back(&mut table_vec); 59 | table_vec::pop_back(&mut table_vec); 60 | table_vec::pop_back(&mut table_vec); 61 | table_vec::destroy_empty(table_vec); 62 | ts::end(scenario); 63 | } 64 | } -------------------------------------------------------------------------------- /contracts/tests/tests/utils/utils.insert_vec_in_vec_set.move: -------------------------------------------------------------------------------- 1 | #[test_only] 2 | module ob_tests::utils_insert_vec_in_vec_set { 3 | use std::vector; 4 | use ob_utils::utils::{Self}; 5 | use sui::vec_set::{Self, VecSet}; 6 | 7 | #[test] 8 | public fun test_insert_vec_in_vec_set_empty_vector() { 9 | let s: VecSet = vec_set::empty(); 10 | let v: vector = vector::empty(); 11 | utils::insert_vec_in_vec_set(&mut s, v); 12 | assert!(vec_set::is_empty(&s), 0); 13 | } 14 | 15 | #[test] 16 | public fun test_insert_vec_in_vec_set_single_entry() { 17 | let s: VecSet = vec_set::empty(); 18 | let v: vector = vector[5]; 19 | utils::insert_vec_in_vec_set(&mut s, v); 20 | assert!(vec_set::size(&s) == 1, 0); 21 | assert!(vec_set::contains(&s, &5), 1); 22 | } 23 | 24 | #[test] 25 | public fun test_insert_vec_in_vec_set_multiple_entries() { 26 | let s: VecSet = vec_set::empty(); 27 | let v: vector = vector[1,2,3]; 28 | utils::insert_vec_in_vec_set(&mut s, v); 29 | assert!(vec_set::size(&s) == 3, 0); 30 | assert!(vec_set::contains(&s, &1), 1); 31 | assert!(vec_set::contains(&s, &2), 2); 32 | assert!(vec_set::contains(&s, &3), 3); 33 | assert!(vec_set::contains(&s, &3), 3); 34 | } 35 | 36 | #[test] 37 | #[expected_failure(abort_code = vec_set::EKeyAlreadyExists)] 38 | public fun test_insert_vec_in_vec_set_with_duplicates() { 39 | let s: VecSet = vec_set::empty(); 40 | let v: vector = vector[1,1,2,2,3,3]; 41 | utils::insert_vec_in_vec_set(&mut s, v); 42 | } 43 | } -------------------------------------------------------------------------------- /contracts/tests/tests/utils/utils.sum_vector.move: -------------------------------------------------------------------------------- 1 | #[test_only] 2 | module ob_tests::utils_sum_vector { 3 | use std::vector; 4 | use ob_utils::utils::{Self}; 5 | const U64_MAX: u64 = 18446744073709551615; 6 | 7 | #[test] 8 | public fun test_sum_vector_empty_vector() { 9 | let v: vector = vector::empty(); 10 | let s = utils::sum_vector(v); 11 | assert!(s == 0, 0); 12 | } 13 | 14 | #[test] 15 | public fun test_sum_vector_single_entry() { 16 | let v: vector = vector[7]; 17 | let s = utils::sum_vector(v); 18 | assert!(s == 7, 0); 19 | } 20 | 21 | #[test] 22 | public fun test_sum_vector_multiple_entries() { 23 | let v: vector = vector[1, 2, 3, 4, 5]; 24 | let s = utils::sum_vector(v); 25 | assert!(s == 15, 0); 26 | } 27 | 28 | #[test] 29 | #[expected_failure(arithmetic_error, location=ob_utils::utils)] 30 | public fun test_sum_vector_overflow() { 31 | let v: vector = vector[U64_MAX, U64_MAX]; 32 | let _s = utils::sum_vector(v); 33 | } 34 | } -------------------------------------------------------------------------------- /contracts/tests/tests/utils/utils.table_from_vec_map.move: -------------------------------------------------------------------------------- 1 | #[test_only] 2 | module ob_tests::test_table_from_vec_map { 3 | use std::ascii; 4 | use ob_utils::utils::{Self}; 5 | use sui::table::{Self}; 6 | use sui::test_scenario as ts; 7 | use sui::vec_map::{Self, VecMap}; 8 | 9 | const TEST_UTILS: address = @0x123; 10 | 11 | #[test] 12 | public fun test_table_from_vec_map_empty_vector() { 13 | let scenario = ts::begin(TEST_UTILS); 14 | let m: VecMap = vec_map::empty(); 15 | 16 | let table = utils::table_from_vec_map(m, ts::ctx(&mut scenario)); 17 | 18 | assert!(table::length(&table) == 0, 0); 19 | table::destroy_empty(table); 20 | ts::end(scenario); 21 | } 22 | 23 | #[test] 24 | public fun test_table_from_vec_map_single_entry() { 25 | let scenario = ts::begin(TEST_UTILS); 26 | let m = vec_map::empty(); 27 | vec_map::insert(&mut m, 88, ascii::string(b"zero")); 28 | 29 | let table = utils::table_from_vec_map(m, ts::ctx(&mut scenario)); 30 | 31 | assert!(table::length(&table) == 1, 0); 32 | 33 | assert!(table::contains(&table, 88), 1); 34 | // check the values 35 | assert!(*table::borrow(&table, 88) == ascii::string(b"zero"), 2); 36 | assert!(table::remove(&mut table, 88) == ascii::string(b"zero"), 0); 37 | // verify that they are not there 38 | assert!(!table::contains(&table, 88), 0); 39 | 40 | table::destroy_empty(table); 41 | ts::end(scenario); 42 | } 43 | 44 | #[test] 45 | public fun test_table_from_vec_map_multiple_entries() { 46 | let scenario = ts::begin(TEST_UTILS); 47 | let m = vec_map::empty(); 48 | vec_map::insert(&mut m, ascii::string(b"hundred"), 100); 49 | vec_map::insert(&mut m, ascii::string(b"thousand"), 1000); 50 | 51 | let table = utils::table_from_vec_map(m, ts::ctx(&mut scenario)); 52 | 53 | assert!(table::length(&table) == 2, 0); 54 | 55 | assert!(table::contains(&table, ascii::string(b"hundred")), 1); 56 | assert!(table::contains(&table, ascii::string(b"thousand")), 1); 57 | 58 | assert!(*table::borrow(&table, ascii::string(b"hundred")) == 100, 2); 59 | assert!(*table::borrow(&table, ascii::string(b"thousand")) == 1000, 2); 60 | 61 | assert!(table::remove(&mut table, ascii::string(b"hundred")) == 100, 3); 62 | assert!(table::remove(&mut table, ascii::string(b"thousand")) == 1000, 3); 63 | 64 | assert!(!table::contains(&table, ascii::string(b"hundred")), 4); 65 | assert!(!table::contains(&table, ascii::string(b"thousand")), 4); 66 | 67 | table::destroy_empty(table); 68 | ts::end(scenario); 69 | } 70 | } -------------------------------------------------------------------------------- /contracts/tests/tests/utils/utils.table_vec_from_vec.move: -------------------------------------------------------------------------------- 1 | #[test_only] 2 | module ob_tests::utils_table_vec_from_vec { 3 | use std::vector; 4 | use ob_utils::utils::{Self}; 5 | use sui::table_vec::{Self}; 6 | use sui::test_scenario as ts; 7 | 8 | const TEST_UTILS: address = @0x123; 9 | 10 | #[test] 11 | public fun test_table_vec_from_vec_empty_vector() { 12 | let scenario = ts::begin(TEST_UTILS); 13 | let ctx = ts::ctx(&mut scenario); 14 | let v: vector = vector::empty(); 15 | 16 | let table_vec = utils::table_vec_from_vec(v, ctx); 17 | 18 | assert!(table_vec::length(&table_vec) == 0, 0); 19 | table_vec::destroy_empty(table_vec); 20 | ts::end(scenario); 21 | } 22 | 23 | #[test] 24 | public fun test_table_vec_from_vec_single_entry() { 25 | let scenario = ts::begin(TEST_UTILS); 26 | let ctx = ts::ctx(&mut scenario); 27 | let v: vector = vector[5]; 28 | 29 | let table_vec = utils::table_vec_from_vec(v, ctx); 30 | 31 | assert!(table_vec::length(&table_vec) == 1, 0); 32 | let value = table_vec::borrow(&table_vec, 0); 33 | assert!(*value == 5, 1); 34 | 35 | table_vec::pop_back(&mut table_vec); 36 | table_vec::destroy_empty(table_vec); 37 | ts::end(scenario); 38 | } 39 | 40 | #[test] 41 | public fun test_table_vec_from_vec_multiple_entries() { 42 | let scenario = ts::begin(TEST_UTILS); 43 | let ctx = ts::ctx(&mut scenario); 44 | let v: vector = vector[1, 2, 3]; 45 | 46 | let table_vec = utils::table_vec_from_vec(v, ctx); 47 | 48 | assert!(table_vec::length(&table_vec) == 3, 0); 49 | let value1 = table_vec::borrow(&table_vec, 0); 50 | assert!(*value1 == 3, 1); 51 | 52 | let value2 = table_vec::borrow(&table_vec, 1); 53 | assert!(*value2 == 2, 2); 54 | 55 | let value3 = table_vec::borrow(&table_vec, 2); 56 | assert!(*value3 == 1, 3); 57 | 58 | table_vec::pop_back(&mut table_vec); 59 | table_vec::pop_back(&mut table_vec); 60 | table_vec::pop_back(&mut table_vec); 61 | table_vec::destroy_empty(table_vec); 62 | ts::end(scenario); 63 | } 64 | } -------------------------------------------------------------------------------- /contracts/tests/tests/utils/utils.vec_map_entries.move: -------------------------------------------------------------------------------- 1 | #[test_only] 2 | module ob_tests::vec_map_entries { 3 | use std::ascii; 4 | use std::vector; 5 | use sui::vec_map::{Self, VecMap}; 6 | use ob_utils::utils::{Self}; 7 | 8 | #[test] 9 | public fun test_vec_map_entries_empty_map() { 10 | let m: VecMap = vec_map::empty(); 11 | let entries = utils::vec_map_entries(&m); 12 | assert!(vector::is_empty(&entries), 0); 13 | } 14 | 15 | #[test] 16 | public fun test_vec_map_entries_single_entry() { 17 | let m = vec_map::empty(); 18 | vec_map::insert(&mut m, 1, 5); 19 | let entries = utils::vec_map_entries(&m); 20 | assert!(entries == vector[5], 0); 21 | } 22 | 23 | #[test] 24 | public fun test_vec_map_entries_multiple_entries() { 25 | let m = vec_map::empty(); 26 | vec_map::insert(&mut m, 0, ascii::string(b"zero")); 27 | vec_map::insert(&mut m, 1, ascii::string(b"one")); 28 | vec_map::insert(&mut m, 2, ascii::string(b"two")); 29 | let entries = utils::vec_map_entries(&m); 30 | assert!(entries == vector[ascii::string(b"zero"), ascii::string(b"one"), ascii::string(b"two")], 0); 31 | } 32 | 33 | #[test] 34 | public fun test_vec_map_entries_non_contiguous_keys() { 35 | let m = vec_map::empty(); 36 | vec_map::insert(&mut m, 1, ascii::string(b"one")); 37 | vec_map::insert(&mut m, 3, ascii::string(b"three")); 38 | vec_map::insert(&mut m, 5, ascii::string(b"five")); 39 | let entries = utils::vec_map_entries(&m); 40 | assert!(entries == vector[ascii::string(b"one"), ascii::string(b"three"), ascii::string(b"five")], 0); 41 | } 42 | 43 | #[test] 44 | public fun test_vec_map_entries_large_map() { 45 | let m: VecMap = vec_map::empty(); 46 | let num_entries = 1000; 47 | let i = 0; 48 | let expected: vector = vector::empty(); 49 | while (i < num_entries) { 50 | vec_map::insert(&mut m, i, i); 51 | vector::push_back(&mut expected, i); 52 | i = i + 1; 53 | }; 54 | let entries = utils::vec_map_entries(&m); 55 | assert!(entries == expected, 0); 56 | } 57 | } -------------------------------------------------------------------------------- /contracts/tests/tests/utils/utils.vec_set_from_vec.move: -------------------------------------------------------------------------------- 1 | #[test_only] 2 | module ob_tests::utils_vec_set_from_vec { 3 | 4 | use std::vector; 5 | use ob_utils::utils::{Self}; 6 | use sui::vec_set::{Self, VecSet}; 7 | 8 | #[test] 9 | public fun test_vec_set_from_vec_empty_vector() { 10 | let v: vector = vector::empty(); 11 | let s: VecSet = utils::vec_set_from_vec(&v); 12 | assert!(vec_set::is_empty(&s), 0); 13 | } 14 | 15 | #[test] 16 | public fun test_vec_set_from_vec_single_entry() { 17 | let v: vector = vector[1]; 18 | let s = utils::vec_set_from_vec(&v); 19 | assert!(vec_set::size(&s) == 1, 0); 20 | assert!(vec_set::contains(&s, &1), 1); 21 | } 22 | 23 | #[test] 24 | public fun test_vec_set_from_vec_multiple_entries() { 25 | let v: vector = vector[1, 2, 3]; 26 | let s = utils::vec_set_from_vec(&v); 27 | assert!(vec_set::size(&s) == 3, 0); 28 | assert!(vec_set::contains(&s, &1), 1); 29 | assert!(vec_set::contains(&s, &2), 2); 30 | assert!(vec_set::contains(&s, &3), 3); 31 | } 32 | 33 | #[test] 34 | #[expected_failure(abort_code = vec_set::EKeyAlreadyExists)] 35 | public fun test_vec_set_from_vec_with_duplicates() { 36 | let v: vector = vector[1,1,2,2,3]; 37 | utils::vec_set_from_vec(&v); 38 | } 39 | } -------------------------------------------------------------------------------- /contracts/utils/Move.lock: -------------------------------------------------------------------------------- 1 | # @generated by Move, please check-in and do not edit manually. 2 | 3 | [move] 4 | version = 0 5 | manifest_digest = "8890F2CF1C8F7BCF79EA07C593928B7376110718226B7D0B976B20EC66EF4D52" 6 | deps_digest = "3C4103934B1E040BB6B23F1D610B4EF9F2F1166A50A104EADCF77467C004C600" 7 | 8 | dependencies = [ 9 | { name = "Pseudorandom" }, 10 | { name = "Sui" }, 11 | ] 12 | 13 | [[move.package]] 14 | name = "MoveStdlib" 15 | source = { git = "https://github.com/MystenLabs/sui.git", rev = "mainnet-v1.19.1", subdir = "crates/sui-framework/packages/move-stdlib" } 16 | 17 | [[move.package]] 18 | name = "Pseudorandom" 19 | source = { local = "../pseudorandom" } 20 | 21 | dependencies = [ 22 | { name = "Sui" }, 23 | ] 24 | 25 | [[move.package]] 26 | name = "Sui" 27 | source = { git = "https://github.com/MystenLabs/sui.git", rev = "mainnet-v1.19.1", subdir = "crates/sui-framework/packages/sui-framework" } 28 | 29 | dependencies = [ 30 | { name = "MoveStdlib" }, 31 | ] 32 | -------------------------------------------------------------------------------- /contracts/utils/Move.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "Utils" 3 | version = "1.7.0" 4 | published-at = "0xd5eaac4e1952473940b120a31bbca4c155fe78b2f0dabd63805e491a3384ecde" 5 | 6 | [dependencies] 7 | Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "mainnet-v1.19.1" } 8 | Pseudorandom = { local = "./../pseudorandom" } 9 | 10 | [addresses] 11 | ob_utils = "0x859eb18bd5b5e8cc32deb6dfb1c39941008ab3c6e27f0b8ce2364be7102bb7cb" 12 | -------------------------------------------------------------------------------- /contracts/utils/sources/math.move: -------------------------------------------------------------------------------- 1 | // Forked from Deepbook 2 | module ob_utils::math { 3 | /// scaling setting for float 4 | const FLOAT_SCALING: u64 = 1_000_000_000; 5 | const FLOAT_SCALING_U128: u128 = 1_000_000_000; 6 | 7 | public fun mul(x: u64, y: u64): u64 { 8 | let x = (x as u128); 9 | let y = (y as u128); 10 | ((x * y / FLOAT_SCALING_U128) as u64) 11 | } 12 | 13 | public fun mul_round(x: u64, y: u64): (bool, u64) { 14 | let x = (x as u128); 15 | let y = (y as u128); 16 | let is_round_down = true; 17 | if ((x * y) % FLOAT_SCALING_U128 == 0) is_round_down = false; 18 | (is_round_down, ((x * y / FLOAT_SCALING_U128) as u64)) 19 | } 20 | 21 | public fun div_round(x: u64, y: u64): (bool, u64) { 22 | let x = (x as u128); 23 | let y = (y as u128); 24 | let is_round_down = true; 25 | if ((x * (FLOAT_SCALING as u128) % y) == 0) is_round_down = false; 26 | (is_round_down, ((x * (FLOAT_SCALING as u128) / y) as u64)) 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /docs/archived/ALLOWLIST.md: -------------------------------------------------------------------------------- 1 | The `nft_protocol::transfer_allowlist` module is a set of functions for 2 | implementing and managing a allowlist for NFT (non-fungible token) transfers. 3 | The transfer allowlist is used to authorize which contracts are allowed to 4 | transfer NFTs of a particular collection. 5 | This allows collection creators to have control over which contracts can 6 | transfer NFTs that belong to their collection. 7 | 8 | For example, if a collection creator wants to enforce royalties on NFT 9 | transfers, they can create a transfer allowlist and add only contracts that are 10 | capable of paying royalties to the allowlist. 11 | Or they can join existing allowlists that only contain audited contracts. 12 | Collection creators can also use the transfer allowlist for other purposes, such 13 | as limiting NFT transfers to certain parties or for complying with legal or 14 | regulatory requirements. 15 | 16 | The `nft_protocol::transfer_allowlist` module includes functions for creating 17 | and managing a allowlist, adding and removing collections from a allowlist, 18 | and checking whether a contract is authorized to transfer a particular NFT. 19 | 20 | In addition to the features previously described, the 21 | `nft_protocol::transfer_allowlist` module allows collection creators to join 22 | multiple allowlists and for anyone to create their own allowlist and invite 23 | creators to join. 24 | This allows for a flexible and customizable approach to managing NFT transfers. 25 | 26 | Collection creators can join multiple allowlists, which allows them to have 27 | their collections included in multiple sets of authorized contracts. 28 | This can be useful if a collection creator wants to allow different groups of 29 | contracts to transfer their NFTs, or if they want to enforce different rules for 30 | different groups of contracts. 31 | For example, a collection creator could create one allowlist for contracts that 32 | pay royalties and another allowlist for contracts that are part of a particular 33 | network or ecosystem. 34 | 35 | This allows for a decentralized and open approach to managing NFT transfers, 36 | where different organizations or groups can create and manage their own 37 | allowlists according to their own rules and criteria. 38 | For example, a decentralized autonomous organization (DAO) could create a 39 | allowlist and invite collection creators to join, allowing the DAO to manage 40 | which contracts are authorized to transfer NFTs from the collections on the 41 | allowlist. 42 | -------------------------------------------------------------------------------- /docs/archived/deploy.md: -------------------------------------------------------------------------------- 1 | # Deploying OriginByte contracts 2 | 3 | To deploy your newly created smart contract in conjunction with the NFT protocol, run the following sh script from the parent folder: 4 | 5 | `./bin/publish.sh` 6 | 7 | Please note that in the current version, the NFT protocol modules will themselves be deployed along with the newly created NFT module. However, in the upcoming version of this tool, newly created NFT modules will tap into a readily deployed contract on-chain. 8 | 9 | To publish the module on-chain, you’ll be required to have a .env file with the field `GAS` and an object ID of the Gas object. To enquire the CLI on what GAS object IDs can be used, you’ll need to be connected to the DevNet, have an active address, and also have the Sui CLI installed. To check for the Gas object ID, run `sui client gas`. Please also note that your active address should be funded via the faucet, and therefore it should have a SUI coin balance available. 10 | -------------------------------------------------------------------------------- /docs/archived/rfc/002-off-chain-listing.md: -------------------------------------------------------------------------------- 1 | # Off-chain listing 2 | 3 | The default way of listing an NFT is to use a client such as a wallet. 4 | The client implements the API of some trading contract. 5 | The API is going to differ contract to contract. 6 | 7 | We explore a pattern which shifts complexity from clients to the trading contracts maintainers. 8 | The clients, such as wallets or marketplaces, only need to know an address of a trading contract. 9 | They don't have to implement the interface (`entry fun`) of the trading contract to list an NFT. 10 | 11 | # Suggested implementation 12 | 13 | A contract is built on top of [`Safe`][rfc-safe] as part of the protocol. 14 | It contains a map between a witness type and `TransferCap`. 15 | An NFT seller's client can call a known `entry fun list()` in this contract. 16 | The trading contract then takes ownership over the `TransferCap` at a later stage in another transaction. 17 | The important point here is that the trading contract maintainer sets up an off-chain service. 18 | The service listens to listing events. 19 | It knows the interface implementation of the trading contract for updating its state. 20 | 21 | For example, two different auction contracts both have different NFT listing implementations. 22 | With this pattern, clients don't have to care about that interface. 23 | Listing (and de-listing) is done via the same client call. 24 | 25 | # Pseudo code 26 | 27 | - The map from witness type to `TransferCap` 28 | 29 | ```move 30 | struct Listing { 31 | transfer_cap: safe::TransferCap, 32 | } 33 | ``` 34 | 35 | - Client's call to list an NFT 36 | 37 | ```move 38 | public entry fun list( 39 | transfer_cap: safe::TransferCap, 40 | ctx: &mut TxContext, 41 | ); 42 | ``` 43 | 44 | - Trading contract's call to take ownership of the `TransferCap` 45 | 46 | ```move 47 | public fun take( 48 | _witness: TradingContractWitness, 49 | listing: &mut Listing, 50 | ): safe::TransferCap; 51 | ``` 52 | 53 | # Further discussion 54 | 55 | 1. It might be useful (as suggested [here][rfc-safe-uid]) to also enable 56 | whitelisting with a `&mut UID` pattern, not only with a witness. 57 | 58 | 2. Clients that list NFTs this way will naturally see a delay to the actual listing in the trading contract. 59 | As opposed to if they implemented the interface themselves. 60 | 61 | 3. How do we enable commissions with this pattern is yet to be explored. 62 | 63 | 64 | 65 | [rfc-safe]: https://github.com/Origin-Byte/nft-protocol/pull/66 66 | [rfc-safe-uid]: https://github.com/Origin-Byte/nft-protocol/pull/66/files#diff-79dfbca015b147c12926127e357acee6ae5afc9f203a4d5eaec9dda6f4618229R144 67 | -------------------------------------------------------------------------------- /example_collections/examples/Move.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "Examples" 3 | version = "1.0.0" 4 | published-at = "0x" 5 | 6 | [dependencies] 7 | Sui = { git = "https://github.com/MystenLabs/sui.git" , subdir = "crates/sui-framework/packages/sui-framework" , rev = "mainnet-v1.19.1" } 8 | NftProtocol = { local = "../../contracts/nft_protocol" } 9 | Launchpad = { local = "../../contracts/launchpad" } 10 | LiquidityLayerV1 = { local = "../../contracts/liquidity_layer_v1" } 11 | 12 | [addresses] 13 | examples = "0x" 14 | -------------------------------------------------------------------------------- /example_collections/loose/extended_types/Move.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "GunExtensions" 3 | version = "1.0.0" 4 | published-at = "0x" 5 | 6 | [dependencies] 7 | Sui = { git = "https://github.com/MystenLabs/sui.git" , subdir = "crates/sui-framework/packages/sui-framework" , rev = "mainnet-v1.19.1" } 8 | NftProtocol = { local = "../../../contracts/nft_protocol" } 9 | Loose = { local = "../main_contract/" } 10 | 11 | [addresses] 12 | gun_extensions = "0x" 13 | -------------------------------------------------------------------------------- /example_collections/loose/extended_types/sources/gun_types.move: -------------------------------------------------------------------------------- 1 | module gun_extensions::gun_types { 2 | struct Ar15 has drop {} 3 | struct Mp40 has drop {} 4 | struct DesertEagle has drop {} 5 | struct Colt has drop {} 6 | 7 | /// Can be used for authorization of other actions post-creation. It is 8 | /// vital that this struct is not freely given to any contract, because it 9 | /// serves as an auth token. 10 | struct Witness has drop {} 11 | } 12 | -------------------------------------------------------------------------------- /example_collections/loose/main_contract/Move.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "Loose" 3 | version = "1.0.0" 4 | published-at = "0x" 5 | 6 | [dependencies] 7 | Sui = { git = "https://github.com/MystenLabs/sui.git" , subdir = "crates/sui-framework/packages/sui-framework" , rev = "mainnet-v1.19.1" } 8 | NftProtocol = { local = "../../../contracts/nft_protocol" } 9 | 10 | [addresses] 11 | loose = "0x" 12 | -------------------------------------------------------------------------------- /example_collections/loose/main_contract/sources/deadbytes.move: -------------------------------------------------------------------------------- 1 | module loose::deadbytes { 2 | use std::string::{utf8, String}; 3 | use std::option; 4 | 5 | use sui::object::UID; 6 | use sui::transfer; 7 | use sui::display; 8 | use sui::package::{Self, Publisher}; 9 | use sui::tx_context::{Self, TxContext}; 10 | 11 | use nft_protocol::collection; 12 | 13 | /// One time witness is only instantiated in the init method 14 | struct DEADBYTES has drop {} 15 | 16 | /// Can be used for authorization of other actions post-creation. It is 17 | /// vital that this struct is not freely given to any contract, because it 18 | /// serves as an auth token. 19 | struct Witness has drop {} 20 | 21 | #[allow(unused_field)] 22 | struct DeadByte has key, store { 23 | id: UID, 24 | } 25 | 26 | #[allow(unused_field)] 27 | struct Gun has key, store { 28 | id: UID, 29 | } 30 | 31 | #[lint_allow(share_owned)] 32 | fun init(otw: DEADBYTES, ctx: &mut TxContext) { 33 | let sender = tx_context::sender(ctx); 34 | 35 | // Init Collection & MintCap with unlimited supply 36 | let (collection, mint_cap) = collection::create_with_mint_cap( 37 | &otw, option::none(), ctx 38 | ); 39 | 40 | // Init Publisher 41 | let publisher = package::claim(otw, ctx); 42 | 43 | transfer::public_transfer(mint_cap, sender); 44 | transfer::public_transfer(publisher, sender); 45 | transfer::public_share_object(collection); 46 | } 47 | 48 | #[lint_allow(self_transfer)] 49 | public fun mint_gun_metadata( 50 | pub: &Publisher, 51 | name: String, 52 | accuracy: String, 53 | recoil: String, 54 | ctx: &mut TxContext, 55 | ) { 56 | assert!(package::from_package(pub), 0); 57 | 58 | let fields = vector[utf8(b"name"), utf8(b"accuracy"), utf8(b"recoil")]; 59 | let values = vector[name, accuracy, recoil]; 60 | 61 | // Get a new `Display` object for the `T` type. 62 | let display = display::new_with_fields( 63 | pub, fields, values, ctx 64 | ); 65 | 66 | // Commit first version of `Display` to apply changes. 67 | display::update_version(&mut display); 68 | 69 | transfer::public_transfer(display, tx_context::sender(ctx)); 70 | } 71 | 72 | #[test_only] 73 | use sui::test_scenario::{Self, ctx}; 74 | #[test_only] 75 | const CREATOR: address = @0xA1C04; 76 | 77 | #[test] 78 | fun it_inits_collection() { 79 | let scenario = test_scenario::begin(CREATOR); 80 | init(DEADBYTES {}, ctx(&mut scenario)); 81 | 82 | test_scenario::end(scenario); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /example_collections/swoots/Move.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "Swoots" 3 | version = "1.0.0" 4 | published-at = "0x" 5 | 6 | [dependencies] 7 | Sui = { git = "https://github.com/MystenLabs/sui.git" , subdir = "crates/sui-framework/packages/sui-framework" , rev = "mainnet-v1.19.1" } 8 | NftProtocol = { local = "../../contracts/nft_protocol" } 9 | Launchpad = { local = "../../contracts/launchpad" } 10 | 11 | [addresses] 12 | swoots = "0x" 13 | -------------------------------------------------------------------------------- /example_collections/swoots/sources/traits/background.move: -------------------------------------------------------------------------------- 1 | module swoots::background { 2 | use std::string::String; 3 | 4 | use sui::tx_context::TxContext; 5 | use sui::object::{Self, UID}; 6 | 7 | friend swoots::swoots; 8 | 9 | struct Background has key, store { 10 | id: UID, 11 | type: String 12 | } 13 | 14 | public(friend) fun mint_background_( 15 | type: String, 16 | ctx: &mut TxContext, 17 | ): Background { 18 | Background { 19 | id: object::new(ctx), 20 | type, 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /example_collections/swoots/sources/traits/clothes.move: -------------------------------------------------------------------------------- 1 | module swoots::clothes { 2 | use std::string::String; 3 | 4 | use sui::tx_context::TxContext; 5 | use sui::object::{Self, UID}; 6 | 7 | friend swoots::swoots; 8 | 9 | struct Clothes has key, store { 10 | id: UID, 11 | type: String 12 | } 13 | 14 | public(friend) fun mint_clothes_( 15 | type: String, 16 | ctx: &mut TxContext, 17 | ): Clothes { 18 | Clothes { 19 | id: object::new(ctx), 20 | type, 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /example_collections/swoots/sources/traits/eyewear.move: -------------------------------------------------------------------------------- 1 | module swoots::eyewear { 2 | use std::string::String; 3 | 4 | use sui::tx_context::TxContext; 5 | use sui::object::{Self, UID}; 6 | 7 | friend swoots::swoots; 8 | 9 | struct Eyewear has key, store { 10 | id: UID, 11 | type: String 12 | } 13 | 14 | public(friend) fun mint_eyewear_( 15 | type: String, 16 | ctx: &mut TxContext, 17 | ): Eyewear { 18 | Eyewear { 19 | id: object::new(ctx), 20 | type, 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /example_collections/swoots/sources/traits/face.move: -------------------------------------------------------------------------------- 1 | module swoots::face { 2 | use std::string::String; 3 | 4 | use sui::tx_context::TxContext; 5 | use sui::object::{Self, UID}; 6 | 7 | friend swoots::swoots; 8 | 9 | struct Face has key, store { 10 | id: UID, 11 | type: String 12 | } 13 | 14 | public(friend) fun mint_face_( 15 | type: String, 16 | ctx: &mut TxContext, 17 | ): Face { 18 | Face { 19 | id: object::new(ctx), 20 | type, 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /example_collections/swoots/sources/traits/fur.move: -------------------------------------------------------------------------------- 1 | module swoots::fur { 2 | use std::string::String; 3 | 4 | use sui::tx_context::TxContext; 5 | use sui::object::{Self, UID}; 6 | 7 | friend swoots::swoots; 8 | 9 | struct Fur has key, store { 10 | id: UID, 11 | type: String 12 | } 13 | 14 | public(friend) fun mint_fur_( 15 | type: String, 16 | ctx: &mut TxContext, 17 | ): Fur { 18 | Fur { 19 | id: object::new(ctx), 20 | type, 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /example_collections/swoots/sources/traits/head.move: -------------------------------------------------------------------------------- 1 | module swoots::head { 2 | use std::string::String; 3 | 4 | use sui::tx_context::TxContext; 5 | use sui::object::{Self, UID}; 6 | 7 | friend swoots::swoots; 8 | 9 | struct Head has key, store { 10 | id: UID, 11 | type: String 12 | } 13 | 14 | public(friend) fun mint_head_( 15 | type: String, 16 | ctx: &mut TxContext, 17 | ): Head { 18 | let head = Head { 19 | id: object::new(ctx), 20 | type, 21 | }; 22 | 23 | head 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /versions/registry-test.json: -------------------------------------------------------------------------------- 1 | {} 2 | --------------------------------------------------------------------------------