Skip to content

Commit

Permalink
feat: Add Intl as a default endowment (#3035)
Browse files Browse the repository at this point in the history
Add `Intl` as a default endowment to allow Snaps to use the browser
native functionality for formatting text and numbers in the UI.

Closes #3034
  • Loading branch information
FrederikBolding authored Jan 23, 2025
1 parent 78dd810 commit 677b049
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const commonEndowments: CommonEndowmentSpecification[] = [
{ endowment: DataView, name: 'DataView' },
{ endowment: Float32Array, name: 'Float32Array' },
{ endowment: Float64Array, name: 'Float64Array' },
{ endowment: Intl, name: 'Intl' },
{ endowment: Int8Array, name: 'Int8Array' },
{ endowment: Int16Array, name: 'Int16Array' },
{ endowment: Int32Array, name: 'Int32Array' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ describe('endowments', () => {
endowments: { crypto },
factory: () => crypto,
},
Intl: {
endowments: { Intl },
factory: () => Intl,
},
mathAttenuated: {
endowments: { mathAttenuated },
factory: () => mathAttenuated,
Expand Down Expand Up @@ -352,6 +356,10 @@ describe('endowments', () => {
factory: expect.any(Function),
names: ['Float64Array'],
},
{
factory: expect.any(Function),
names: ['Intl'],
},
{
factory: expect.any(Function),
names: ['Int8Array'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ describe('getEndowments', () => {
"Uint16Array",
"Int32Array",
"isSecureContext",
"Intl",
"Uint32Array",
"Float32Array",
"Float64Array",
Expand Down
1 change: 1 addition & 0 deletions packages/snaps-utils/src/default-endowments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const DEFAULT_ENDOWMENTS: readonly string[] = Object.freeze([
'Uint16Array',
'Int32Array',
'isSecureContext',
'Intl',
'Uint32Array',
'Float32Array',
'Float64Array',
Expand Down

0 comments on commit 677b049

Please sign in to comment.