Skip to content
Open
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
4 changes: 3 additions & 1 deletion .wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -459,4 +459,6 @@ Kiskesis
CIDs
setSpecsFromKeypomParams
generatePerUsePasswords
ETHGlobal
ETHGlobal
codeblock
Keypom
25 changes: 25 additions & 0 deletions docs/Cookbook/balances.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@ const userBal = await getUserBalance({
console.log('userBal: ', userBal)
```

</TabItem>
<TabItem value="CONTRACT" label="🦀 Rust Function Prototypes">

```rust
pub fn get_user_balance(
&self,
account_id: AccountId
) -> U128
```

</TabItem>

</Tabs>
Expand All @@ -49,6 +59,14 @@ await addToBalance({
});
```

</TabItem>
<TabItem value="CONTRACT" label="🦀 Rust Function Prototypes">

```rust
// Attached deposit will be added to predecessor's balance
pub fn add_to_balance(&mut self)
```

</TabItem>

</Tabs>
Expand All @@ -66,6 +84,13 @@ await withdrawBalance({
account: fundingAccount
})
```
</TabItem>
<TabItem value="CONTRACT" label="🦀 Rust Function Prototypes">

```rust
// Prececessor's balance will be withdrawn to their NEAR wallet
pub fn add_to_balance(&mut self)
```

</TabItem>

Expand Down
106 changes: 105 additions & 1 deletion docs/Cookbook/drops/NEAR.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,30 @@ const {keys} = await createDrop({
account: fundingAccount,
numKeys: 2,
depositPerUseNEAR: "0.1",
});

});
console.log(keys)
```

</TabItem>
<TabItem value="CONTRACT" label="🦀 Rust Function Prototypes">

```rust
pub fn create_drop(
&mut self,
// How much $NEAR should be transferred everytime a key is used? Can be 0.
deposit_per_use: U128,
) -> Option<DropIdJson>

pub fn add_keys(
&mut self,
// Public keys to add
public_keys: Vec<PublicKey>,
// Overload the specific drop ID
drop_id: DropIdJson,
) -> Option<DropIdJson>
```

</TabItem>
</Tabs>

Expand Down Expand Up @@ -73,6 +92,54 @@ while (keysAdded < numKeys) {
}
```

</TabItem>
<TabItem value="CONTRACT" label="🦀 Rust Function Prototypes">

```rust
pub fn create_drop(
&mut self,
// How much $NEAR should be transferred everytime a key is used? Can be 0.
deposit_per_use: U128,
) -> Option<DropIdJson>

pub fn add_keys(
&mut self,
// Public keys to add
public_keys: Vec<PublicKey>,
// Overload the specific drop ID
drop_id: DropIdJson,
) -> Option<DropIdJson>
```

</TabItem>

</Tabs>

___

## Viewing Drops by Owner
To view all drops created by one account, you can use the following.

<Tabs>
<TabItem value="SDK" label="🔑 Keypom SDK">

```js
// Creating drop with 0 single use keys
const dropsForOwner = await getDrops({accountId: "minqi.testnet"});
```

</TabItem>
<TabItem value="CONTRACT" label="🦀 Rust Function Prototypes">

```rust
pub fn get_drops_for_owner(
&self,
account_id: AccountId,
from_index: Option<U128>,
limit: Option<u64>,
) -> Vec<JsonDrop>
```

</TabItem>

</Tabs>
Expand All @@ -82,6 +149,10 @@ ___
## Delete Drop
A drop can be deleted manually at any time using `deleteDrops`. This will refund all unclaimed key balances back to the drop funder's Keypom balance.

The Keypom contract does not have a `deleteDrops` equivalent function. Behind the scenes of the SDK, the keys are being collected, refunded and then deleted.

The first step in this process is to use `get_key_supply_for_drop`. Once the total key supply is found, 50 keys at a time are retrieved using `get_keys_for_drop` and refunding their associated assets and deleting the keys using `refund_assets` and `delete_keys` respectively.

<Tabs>
<TabItem value="SDK" label="🔑 Keypom SDK">

Expand All @@ -102,6 +173,39 @@ await deleteDrops({
})
```

</TabItem>
<TabItem value="CONTRACT" label="🦀 Rust Function Prototypes">

```rust
// Get total number of keys
pub fn get_key_supply_for_drop(&self, drop_id: DropIdJson) -> u64

// Get 50 keys at a time, this might need to be looped depending on key supply
pub fn get_keys_for_drop(
&self,
drop_id: DropIdJson,
from_index: Option<U128>,
limit: 50,
) -> Vec<JsonKeyInfo>

// Refund the assets in those keys
// assets_to_refund indicated the number of assets to refund. If not specified, all assets will be attempted to be refunded.
pub fn refund_assets(
&mut self,
drop_id: DropIdJson,
assets_to_refund: Option<u64>
)

// Delete keys that were retrieved.
pub fn delete_keys(
&mut self,
drop_id: DropIdJson,
public_keys: Option<Vec<PublicKey>>,
limit: Option<u8>,
delete_on_empty: Option<bool>,
)
```

</TabItem>

</Tabs>
Expand Down
46 changes: 46 additions & 0 deletions docs/Cookbook/drops/customizations/dropConfig.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,28 @@ const {keys} = await createDrop({
console.log(keys)
```

</TabItem>
<TabItem value="CONTRACT" label="🦀 Rust Function Prototypes">

```rust
pub fn create_drop(
&mut self,
// How much $NEAR should be transferred everytime a key is used? Can be 0.
deposit_per_use: U128,
config:{
uses_per_key: u64
}
) -> Option<DropIdJson>

pub fn add_keys(
&mut self,
// Public keys to add
public_keys: Vec<PublicKey>,
// Overload the specific drop ID
drop_id: DropIdJson,
) -> Option<DropIdJson>
```

</TabItem>

</Tabs>
Expand Down Expand Up @@ -66,6 +88,30 @@ const {keys} = await createDrop({
console.log(keys)
```

</TabItem>
<TabItem value="CONTRACT" label="🦀 Rust Function Prototypes">

```rust
pub fn create_drop(
&mut self,
// How much $NEAR should be transferred everytime a key is used? Can be 0.
deposit_per_use: U128,
config:{
usage:{
root_account_id: "mint-brigade.testnet"
}
}
) -> Option<DropIdJson>

pub fn add_keys(
&mut self,
// Public keys to add
public_keys: Vec<PublicKey>,
// Overload the specific drop ID
drop_id: DropIdJson,
) -> Option<DropIdJson>
```

</TabItem>

</Tabs>
Expand Down
103 changes: 103 additions & 0 deletions docs/Cookbook/drops/customizations/password.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,32 @@ let {keys, dropId} = await createDrop({
console.log(keys)
```

</TabItem>
<TabItem value="CONTRACT" label="🦀 Rust Function Prototypes">

```rust
pub fn create_drop(
&mut self,
// How much $NEAR should be transferred everytime a key is used? Can be 0.
deposit_per_use: U128,
// Passwords for the keys
passwords_per_use: Option<Vec<Option<Vec<{
// What is the password for this use
pw: String,
// Which use does this pertain to
key_use: u64,
}>>>>
) -> Option<DropIdJson>

pub fn add_keys(
&mut self,
// Public keys to add
public_keys: Vec<PublicKey>,
// Overload the specific drop ID
drop_id: DropIdJson,
) -> Option<DropIdJson>
```

</TabItem>

</Tabs>
Expand Down Expand Up @@ -106,6 +132,46 @@ let {keys, dropId} = await createDrop({
console.log(keys)
```

</TabItem>
<TabItem value="CONTRACT" label="🦀 Rust Function Prototypes">

```rust
pub fn create_drop(
&mut self,
// How much $NEAR should be transferred everytime a key is used? Can be 0.
deposit_per_use: U128,
// Passwords for the keys
passwords_per_use: [
[
{
pw: hash(hash("my_first_pw"))
key_use: 1
}
],
[
{
pw: ""
key_use: 2
}
],
[
{
pw: hash(hash("my_next_pw"))
key_use: 3
}
],
]
) -> Option<DropIdJson>

pub fn add_keys(
&mut self,
// Public keys to add
public_keys: Vec<PublicKey>,
// Overload the specific drop ID
drop_id: DropIdJson,
) -> Option<DropIdJson>
```

</TabItem>

</Tabs>
Expand All @@ -115,6 +181,10 @@ ___
## Delete Drop
A drop can be deleted manually at any time using `deleteDrops`. This will refund all unclaimed key balances back to the drop funder's Keypom balance.

The Keypom contract does not have a `deleteDrops` equivalent function. Behind the scenes of the SDK, the keys are being collected, refunded and then deleted.

The first step in this process is to use `get_key_supply_for_drop`. Once the total key supply is found, 50 keys at a time are retrieved using `get_keys_for_drop` and refunding their associated assets and deleting the keys using `refund_assets` and `delete_keys` respectively.

<Tabs>
<TabItem value="SDK" label="🔑 Keypom SDK">

Expand All @@ -135,6 +205,39 @@ await deleteDrops({
})
```

</TabItem>
<TabItem value="CONTRACT" label="🦀 Rust Function Prototypes">

```rust
// Get total number of keys
pub fn get_key_supply_for_drop(&self, drop_id: DropIdJson) -> u64

// Get 50 keys at a time, this might need to be looped depending on key supply
pub fn get_keys_for_drop(
&self,
drop_id: DropIdJson,
from_index: Option<U128>,
limit: 50,
) -> Vec<JsonKeyInfo>

// Refund the assets in those keys
// assets_to_refund indicated the number of assets to refund. If not specified, all assets will be attempted to be refunded.
pub fn refund_assets(
&mut self,
drop_id: DropIdJson,
assets_to_refund: Option<u64>
)

// Delete keys that were retrieved.
pub fn delete_keys(
&mut self,
drop_id: DropIdJson,
public_keys: Option<Vec<PublicKey>>,
limit: Option<u8>,
delete_on_empty: Option<bool>,
)
```

</TabItem>

</Tabs>
Expand Down
Loading