forked from rhinestonewtf/module-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request rhinestonewtf#80 from rhinestonewtf/feat/encode-va…
…lidator-nonce feat: add encode validator nonce helper
- Loading branch information
Showing
13 changed files
with
99 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Hex, PublicClient } from 'viem' | ||
import { Account } from '../types' | ||
import { getAccountImplementation } from './getAccountImplementation' | ||
import { Module } from '../../module/types' | ||
|
||
export const encodeValidatorNonce = ({ | ||
account, | ||
validator, | ||
}: { | ||
account: Account | ||
validator: Module | ||
}): bigint => { | ||
const accountImplementation = getAccountImplementation({ account }) | ||
return accountImplementation.encodeValidatorNonce({ | ||
validator, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
src/account/erc7579-implementation/api/encodeValidatorNonce.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { pad } from 'viem' | ||
import { Module } from '../../../module/types' | ||
|
||
export const encodeValidatorNonce = ({ validator }: { validator: Module }) => { | ||
return BigInt( | ||
pad(validator.address, { | ||
dir: 'right', | ||
size: 24, | ||
}), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { pad, encodePacked } from 'viem' | ||
import { KernelModule } from '../types' | ||
|
||
export const encodeValidatorNonce = ({ | ||
validator, | ||
}: { | ||
validator: KernelModule | ||
}) => { | ||
return BigInt( | ||
pad( | ||
encodePacked( | ||
['bytes1', 'bytes1', 'address'], | ||
['0x00', '0x00', validator.address], | ||
), | ||
{ | ||
dir: 'right', | ||
size: 24, | ||
}, | ||
), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { pad } from 'viem' | ||
import { Module } from '../../../module/types' | ||
|
||
export const encodeValidatorNonce = ({ validator }: { validator: Module }) => { | ||
return BigInt( | ||
pad(validator.address, { | ||
dir: 'right', | ||
size: 24, | ||
}), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { pad } from 'viem' | ||
import { Module } from '../../../module/types' | ||
|
||
export const encodeValidatorNonce = ({ validator }: { validator: Module }) => { | ||
return BigInt( | ||
pad(validator.address, { | ||
dir: 'right', | ||
size: 24, | ||
}), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters