-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat:
getFrameMessage
can now handle mock frame messages. (#149)
- Loading branch information
Showing
6 changed files
with
144 additions
and
2 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,5 @@ | ||
--- | ||
'@coinbase/onchainkit': minor | ||
--- | ||
|
||
- **feat**: `getFrameMessage` can now handle mock frame messages. When `allowFramegear` is passed as an option (defaults to `false`), it will skip validating which facilitates testing locally running apps with future releases of `framegear`. |
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,37 @@ | ||
import { FrameRequest, MockFrameRequest, MockFrameRequestOptions } from './types'; | ||
|
||
/** | ||
* Modify a standard frame request to include simulated values (e.g., indicate the viewer | ||
* follows the cast author) for development/debugging purposes. | ||
* @param request A standard frame request. | ||
* @param options An object containing values we will pretend are real for the purposes of debugging. | ||
* @returns | ||
*/ | ||
function getMockFrameRequest( | ||
request: FrameRequest, | ||
options?: MockFrameRequestOptions, | ||
): MockFrameRequest { | ||
return { | ||
...request, | ||
mockFrameData: { | ||
button: request.untrustedData.buttonIndex, | ||
input: request.untrustedData.inputText, | ||
following: !!options?.following, | ||
interactor: { | ||
fid: options?.interactor?.fid || 0, | ||
custody_address: options?.interactor?.custody_address || '0xnotarealaddress', | ||
verified_accounts: options?.interactor?.verified_accounts || [], | ||
}, | ||
liked: !!options?.liked, | ||
recasted: !!options?.recasted, | ||
valid: true, | ||
raw: { | ||
valid: true, | ||
// TODO: unjank | ||
action: {} as any, | ||
}, | ||
}, | ||
}; | ||
} | ||
|
||
export { getMockFrameRequest }; |
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