Skip to content

Commit

Permalink
Merge pull request #74 from pactsafe/IRON-15160-React-SDK-Support-for…
Browse files Browse the repository at this point in the history
…-Snapshots

IRON-15160 react sdk support for snapshots
  • Loading branch information
jasonabrown authored Jun 7, 2023
2 parents d9859fb + 809c4aa commit 3f248cc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ You can hook into events using the triggered event callback props described here
| `renderData` | Object containing the dynamic render data for your contract. [For more information on using dynamic contracts, check out this documentation.](https://developer.pactsafe.com/docs/how-to-use-smart-contracts-with-the-javascript-library) | object | If `dynamic` is set to true | undefined |
| `signerIdSelector` | The ID of the `<input>` element that will be used to identify the signer. | string | Yes | Required Value |
| `signerId` | Use this to set the signer id directly. Note that if this value is tied to a state variable updated via user input, you may hit rate limits if it is updated frequently in a short period of time. To avoid hitting a rate limit, it is best to set the value tied to this prop only when the user's input is complete as opposed to changing this value on a per character basis. | string | No, unless `signerIdSelector` is not passed | undefined |
| `snapshotLocation` | Ironclad Clickwrap Snapshot Location Key, this is found within the Snapshot Location configuration | string | No | undefined |
| `testMode` | Enable this to register any contract acceptances as test data that can be cleared within the Ironclad Clickwrap UI | bool | No | false |
| `allowDisagreed` | Enable this to allow invalid events to be triggered when a signer unchecks a checkbox. | bool | If `onInvalid` is passed | false |
| `onAll` | See [onAll](#onAll) below | function | No | undefined |
Expand Down
10 changes: 10 additions & 0 deletions src/PSClickWrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class PSClickWrap extends React.Component {
injectSnippetOnly,
renderData,
signerId,
snapshotLocation,
} = this.props;
const { clickwrapGroupKey, dynamicGroup } = this.state;
const _psLoadedValidGroup = _ps
Expand Down Expand Up @@ -113,6 +114,9 @@ class PSClickWrap extends React.Component {
if (clickWrapStyle && _psLoadedValidGroup) { _ps.getByKey(clickwrapGroupKey).site.set('style', clickWrapStyle); }
_ps('set', 'signer_id', signerId);
}
if (snapshotLocation !== prevProps.snapshotLocation) {
_ps('set', 'snapshot_location', snapshotLocation);
}
if (clickWrapStyle !== prevProps.clickWrapStyle && dynamicGroup) {
this.createClickWrap();
}
Expand Down Expand Up @@ -212,6 +216,7 @@ class PSClickWrap extends React.Component {
injectSnippetOnly,
renderData,
signerIdSelector,
snapshotLocation,
allowDisagreed,
} = this.props;
const options = {
Expand Down Expand Up @@ -253,6 +258,10 @@ class PSClickWrap extends React.Component {
if (customData) {
_ps('set', 'custom_data', customData);
}

if (snapshotLocation) {
_ps('set', 'snapshot_location', snapshotLocation);
}

if (groupKey) {
_ps('load', groupKey, { ...options, event_callback: eventCallback });
Expand Down Expand Up @@ -316,6 +325,7 @@ PSClickWrap.propTypes = {
(props) => !props.hasOwnProperty('signerIdSelector') && !props.hasOwnProperty('injectSnippetOnly'),
PSClickWrap.MUST_PROVIDE_SIGNER_ID_OR_SIGNER_ID_SELECTOR,
),
snapshotLocation: PropTypes.string,
testMode: PropTypes.bool,
allowDisagreed: isRequiredIf(
PropTypes.bool,
Expand Down

0 comments on commit 3f248cc

Please sign in to comment.