Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

task6 #2076

Closed
wants to merge 1 commit into from
Closed

task6 #2076

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions mover/nextuser/code/task6/navi-demo/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
32 changes: 32 additions & 0 deletions mover/nextuser/code/task6/navi-demo/06.SDK_PTB_NAVI.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# 用 Sui SDK 和 Navi SDK 在Navi Protocol 存入 1 SUI

- 上链网络: 主网(mainnet)

## 特别感谢

- 本 task 由 [Navi Protocol](https://app.naviprotocol.io) 特别赞助

## 需求

- 完成 dapp-kit 学习
- 完成 Sui SDK 学习
- 完成 PTB的概念学习
- 完成 Navi Protocol 学习
- 在 dapp-kit里面用chrome钱包签名提交
- 完成 必须在同一个PTB完成 Navi SDK 1.[存入Navi Protocol 1 SUI] 2.[借出当前日期的USDC 0.[月][天][小时] 的 USDC ]
3.[然后在存入等额的USDC]

> 当前时间是2024年4月25日15点 借出的金额就是 `0.042515` 月 天 小时 必须是两位数 2024年5月1日2点 `0.050102`

## 报错信息

> 如果遇到报错可能是更新了 `package id` 下面可以看到最新的id 替换一下sdk的值就行
https://open-api.naviprotocol.io/api/package

## 任务指南

- [sui sdk](https://sdk.mystenlabs.com/typescript)
- [ptb sdk](https://sdk.mystenlabs.com/typescript/transaction-building/basics)
- [ptb concepts](https://docs.sui.io/concepts/transactions/prog-txn-blocks)
- [navi-sdk](https://github.com/naviprotocol/navi-sdk)
- [navi-docs](https://naviprotocol.gitbook.io/navi-protocol-developer-docs/how-to-interact-with-the-contract/navi-sdk/api-interface)
102 changes: 102 additions & 0 deletions mover/nextuser/code/task6/navi-demo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# Sui dApp Starter Template

This dApp was created using `@mysten/create-dapp` that sets up a basic React
Client dApp using the following tools:

- [React](https://react.dev/) as the UI framework
- [TypeScript](https://www.typescriptlang.org/) for type checking
- [Vite](https://vitejs.dev/) for build tooling
- [Radix UI](https://www.radix-ui.com/) for pre-built UI components
- [ESLint](https://eslint.org/) for linting
- [`@mysten/dapp-kit`](https://sdk.mystenlabs.com/dapp-kit) for connecting to
wallets and loading data
- [pnpm](https://pnpm.io/) for package management

For a full guide on how to build this dApp from scratch, visit this
[guide](http://docs.sui.io/guides/developer/app-examples/e2e-counter#frontend).

## Deploying your Move code

### Install Sui cli

Before deploying your move code, ensure that you have installed the Sui CLI. You
can follow the [Sui installation instruction](https://docs.sui.io/build/install)
to get everything set up.

This template uses `testnet` by default, so we'll need to set up a testnet
environment in the CLI:

```bash
sui client new-env --alias testnet --rpc https://fullnode.testnet.sui.io:443
sui client switch --env testnet
```

If you haven't set up an address in the sui client yet, you can use the
following command to get a new address:

```bash
sui client new-address secp256k1
```

This well generate a new address and recover phrase for you. You can mark a
newly created address as you active address by running the following command
with your new address:

```bash
sui client switch --address 0xYOUR_ADDRESS...
```

We can ensure we have some Sui in our new wallet by requesting Sui from the
faucet (make sure to replace the address with your address):

```bash
curl --location --request POST 'https://faucet.testnet.sui.io/gas' \
--header 'Content-Type: application/json' \
--data-raw '{
"FixedAmountRequest": {
"recipient": "<YOUR_ADDRESS>"
}
}'
```

### Publishing the move package

The move code for this template is located in the `move` directory. To publish
it, you can enter the `move` directory, and publish it with the Sui CLI:

```bash
cd move
sui client publish --gas-budget 100000000 counter
```

In the output there will be an object with a `"packageId"` property. You'll want
to save that package ID to the `src/constants.ts` file as `PACKAGE_ID`:

```ts
export const TESTNET_COUNTER_PACKAGE_ID = "<YOUR_PACKAGE_ID>";
```

Now that we have published the move code, and update the package ID, we can
start the app.

## Starting your dApp

To install dependencies you can run

```bash
pnpm install
```

To start your dApp in development mode run

```bash
pnpm dev
```

## Building

To build your app for deployment you can run

```bash
pnpm build
```
59 changes: 59 additions & 0 deletions mover/nextuser/code/task6/navi-demo/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<!doctype html>
<html lang="en" class="dark-theme" style="color-scheme: dark">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Sui dApp Starter</title>

<style>
/*
Josh's Custom CSS Reset
https://www.joshwcomeau.com/css/custom-css-reset/
*/
*,
*::before,
*::after {
box-sizing: border-box;
}
* {
margin: 0;
}
body {
line-height: 1.5;
-webkit-font-smoothing: antialiased;
}
img,
picture,
video,
canvas,
svg {
display: block;
max-width: 100%;
}
input,
button,
textarea,
select {
font: inherit;
}
p,
h1,
h2,
h3,
h4,
h5,
h6 {
overflow-wrap: break-word;
}
#root,
#__next {
isolation: isolate;
}
</style>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
135 changes: 135 additions & 0 deletions mover/nextuser/code/task6/navi-demo/navi.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
# entry deposit
MoveCall 1

entry_deposit
Package:
0xe66f07e2a8d9cf793da1e0bca98ff312b3ffba57228d97cf23a0613fddf31b65
Module:
incentive_v2
Function:
entry_deposit
Type Arguments:
0xaf8cd5edc19c4512f4259f0bee101a40d41ebed738ade5874359610ef8eeced5::coin::COIN
Arguments:
[
0: {
type: "object"
objectType: "sharedObject"
objectId: "0x0000000000000000000000000000000000000000000000000000000000000006"
initialSharedVersion: "1"
mutable: false
}
1: {
type: "object"
objectType: "sharedObject"
objectId: "0xbb4e2f4b6205c2e2a2db47aeb4f830796ec7c005f88537ee775986639bc442fe"
initialSharedVersion: "8202844"
mutable: true
}
2: {
type: "object"
objectType: "sharedObject"
objectId: "0x71b9f6e822c48ce827bceadce82201d6a7559f7b0350ed1daa1dc2ba3ac41b56"
initialSharedVersion: "26605571"
mutable: true
}
3: {
type: "pure"
valueType: "u8"
value: 3
}
4: {
type: "object"
objectType: "immOrOwnedObject"
objectId: "0x538bb16b9c4035d4c49fadd3ae549b32d9ce5cb8c31354c1788cd6b5890339ea"
version: "39427224"
digest: "Gn6YkonRw2VqUmU3to9sSm3Akx84vKX5FPCQo43SK65s"
}
5: {
type: "pure"
valueType: "u64"
value: "2777"
}
6: {
type: "object"
objectType: "sharedObject"
objectId: "0xaaf735bf83ff564e1b219a0d644de894ef5bdc4b2250b126b2a46dd002331821"
initialSharedVersion: "8202844"
mutable: true
}
7: {
type: "object"
objectType: "sharedObject"
objectId: "0xf87a8acb8b81d14307894d12595541a73f19933f88e1326d5be349c7a6f7559c"
initialSharedVersion: "38232222"
mutable: true
}
]

# navi withdraw
MoveCall 0

entry_withdraw
Package:
0xe66f07e2a8d9cf793da1e0bca98ff312b3ffba57228d97cf23a0613fddf31b65
Module:
incentive_v2
Function:
entry_withdraw
Type Arguments:
0xaf8cd5edc19c4512f4259f0bee101a40d41ebed738ade5874359610ef8eeced5::coin::COIN
Arguments:
[
0: {
type: "object"
objectType: "sharedObject"
objectId: "0x0000000000000000000000000000000000000000000000000000000000000006"
initialSharedVersion: "1"
mutable: false
}
1: {
type: "object"
objectType: "sharedObject"
objectId: "0x1568865ed9a0b5ec414220e8f79b3d04c77acc82358f6e5ae4635687392ffbef"
initialSharedVersion: "8202835"
mutable: false
}
2: {
type: "object"
objectType: "sharedObject"
objectId: "0xbb4e2f4b6205c2e2a2db47aeb4f830796ec7c005f88537ee775986639bc442fe"
initialSharedVersion: "8202844"
mutable: true
}
3: {
type: "object"
objectType: "sharedObject"
objectId: "0x71b9f6e822c48ce827bceadce82201d6a7559f7b0350ed1daa1dc2ba3ac41b56"
initialSharedVersion: "26605571"
mutable: true
}
4: {
type: "pure"
valueType: "u8"
value: 3
}
5: {
type: "pure"
valueType: "u64"
value: "777"
}
6: {
type: "object"
objectType: "sharedObject"
objectId: "0xaaf735bf83ff564e1b219a0d644de894ef5bdc4b2250b126b2a46dd002331821"
initialSharedVersion: "8202844"
mutable: true
}
7: {
type: "object"
objectType: "sharedObject"
objectId: "0xf87a8acb8b81d14307894d12595541a73f19933f88e1326d5be349c7a6f7559c"
initialSharedVersion: "38232222"
mutable: true
}
]
Loading