Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: MetaMask/eth-sig-util
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v8.0.0
Choose a base ref
...
head repository: MetaMask/eth-sig-util
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v8.1.0
Choose a head ref
  • 2 commits
  • 3 files changed
  • 3 contributors

Commits on Dec 2, 2024

  1. Add permit type schema (#399)

    OGPoyraz authored Dec 2, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    eaa3bdf View commit details

Commits on Dec 3, 2024

  1. 8.1.0 (#400)

    * 8.1.0
    
    * Adjust changelog
    
    ---------
    
    Co-authored-by: github-actions <[email protected]>
    Co-authored-by: OGPoyraz <[email protected]>
    3 people authored Dec 3, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    1a02afc View commit details
Showing with 27 additions and 2 deletions.
  1. +6 −1 CHANGELOG.md
  2. +1 −1 package.json
  3. +20 −0 src/sign-typed-data.ts
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [8.1.0]
### Added
- Add `Permit` type to `signTypedData` schema ([#399](https://github.com/MetaMask/eth-sig-util/pull/399))

## [8.0.0]
### Changed
- **BREAKING**: Values of type `number` are not accepted as address parameter anymore. Valid values are `string` and `Uint8Array`. ([#391](https://github.com/MetaMask/eth-sig-util/pull/391))
@@ -158,7 +162,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fix package metadata ([#81](https://github.com/MetaMask/eth-sig-util/pull/81)
- Switch from Node.js v8 to Node.js v10 ([#76](https://github.com/MetaMask/eth-sig-util/pull/77) and [#80](https://github.com/MetaMask/eth-sig-util/pull/80))

[Unreleased]: https://github.com/MetaMask/eth-sig-util/compare/v8.0.0...HEAD
[Unreleased]: https://github.com/MetaMask/eth-sig-util/compare/v8.1.0...HEAD
[8.1.0]: https://github.com/MetaMask/eth-sig-util/compare/v8.0.0...v8.1.0
[8.0.0]: https://github.com/MetaMask/eth-sig-util/compare/v7.0.3...v8.0.0
[7.0.3]: https://github.com/MetaMask/eth-sig-util/compare/v7.0.2...v7.0.3
[7.0.2]: https://github.com/MetaMask/eth-sig-util/compare/v7.0.1...v7.0.2
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@metamask/eth-sig-util",
"version": "8.0.0",
"version": "8.1.0",
"description": "A few useful functions for signing ethereum data",
"keywords": [
"ethereum",
20 changes: 20 additions & 0 deletions src/sign-typed-data.ts
Original file line number Diff line number Diff line change
@@ -105,6 +105,22 @@ export type TypedMessage<T extends MessageTypes> = {
message: Record<string, unknown>;
};

const PERMIT_TYPE_SCHEMA = {
properties: {
message: {
type: 'object',
properties: {
owner: { type: 'string' },
spender: { type: 'string' },
value: { type: 'string' },
nonce: { type: 'string' },
deadline: { type: 'string' },
},
required: ['owner', 'spender', 'value', 'nonce', 'deadline'],
},
},
};

export const TYPED_MESSAGE_SCHEMA = {
type: 'object',
properties: {
@@ -127,6 +143,10 @@ export const TYPED_MESSAGE_SCHEMA = {
message: { type: 'object' },
},
required: ['types', 'primaryType', 'domain', 'message'],
if: {
properties: { primaryType: { const: 'Permit' } },
},
then: PERMIT_TYPE_SCHEMA,
};

/**