Skip to content

Commit

Permalink
Merge pull request #104 from coinbase/conner/spend-permissions-12/6
Browse files Browse the repository at this point in the history
  • Loading branch information
ilikesymmetry authored Dec 6, 2024
2 parents d8cc8ff + b9f55c0 commit 9d65b14
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Callout } from 'vocs/components';
import { Callout } from "vocs/components";

# `SpendPermissionManager.sol` smart contract

Expand All @@ -10,8 +10,9 @@ The open-source contracts repository is [here](https://github.com/coinbase/spend

Defines the complete parameters of a spend permission.

<Callout type="warning" >
The fields of the `SpendPermission` structure must be strictly ordered as defined below.
<Callout type="warning">
The fields of the `SpendPermission` structure must be strictly ordered as
defined below.
</Callout>

| Field | Type | Description |
Expand Down Expand Up @@ -92,14 +93,44 @@ function getHash(SpendPermission memory spendPermission) public view returns (by

#### `isApproved`

Check if a spend permission is approved and not revoked, regardless of whether the current time is within the valid time range of the permission.
Check if a spend permission is approved, regardless of whether the current time is within the valid time range of the permission.

```solidity
function isApproved(SpendPermission memory spendPermission) public view returns (bool);
```

---

#### `isRevoked`

Check if a spend permission is revoked, regardless of whether the current time is within the valid time range of the permission.

```solidity
function isRevoked(SpendPermission memory spendPermission) public view returns (bool);
```

---

#### `isValid`

Check if a spend permission is approved and not revoked, regardless of whether the current time is within the valid time range of the permission.

```solidity
function isValid(SpendPermission memory spendPermission) public view returns (bool);
```

---

#### `getLastUpdatedPeriod`

Retrieve the `start`, `end`, and accumulated `spend` for the last updated period of a spend permission.

```solidity
function getLastUpdatedPeriod(SpendPermission memory spendPermission) public view returns (PeriodSpend memory);
```

---

#### `getCurrentPeriod`

Retrieve the `start`, `end`, and accumulated `spend` for the current period of a spend permission.
Expand Down
6 changes: 3 additions & 3 deletions docs/pages/guides/spend-permissions/quick-start.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ NEXT_PUBLIC_SPENDER_ADDRESS=
</Callout>

Our spender will need to sign transactions from our app, so we'll create a wallet (private key and address) for our spender.
If you have [Foundry](https://book.getfoundry.sh/) installed, you can generate a new wallet via `cast wallet new`. If you already have a
If you have [Foundry](https://book.getfoundry.sh/) installed, you can generate a new wallet via `cast wallet new`. If you already have a
development keypair you can use that too. Assign the private key and address to
`SPENDER_PRIVATE_KEY` and `NEXT_PUBLIC_SPENDER_ADDRESS`, respectively.

Expand Down Expand Up @@ -342,7 +342,7 @@ export default function Subscribe() {
}
```

Also be sure to add this new `Subscribe` button component to the top level component in `page.tsx`.
Also be sure to add this new `Subscribe` button component to the top level component in `page.tsx`.
You can delete lines 77-127 and put your button there.

```tsx [page.tsx]
Expand All @@ -363,7 +363,7 @@ You can delete lines 77-127 and put your button there.
### Examine the `SpendPermission` object our user will sign

A `SpendPermission` is the struct that defines the parameters of the permission.
See the solidity struct [here](https://github.com/coinbase/spend-permissions/blob/07067168108b83d9662435b056a2a580c08be214/src/SpendPermissionManager.sol#L20).
See the solidity struct [here](https://github.com/coinbase/spend-permissions/blob/main/src/SpendPermissionManager.sol#L18-L38).

You can see the spend permission object being defined in lines 49-59 of our `Subscribe` component:

Expand Down

0 comments on commit 9d65b14

Please sign in to comment.